Dropbox API Support & Feedback
Find help with the Dropbox API from other developers.
Hi,
I have an HTML/JS webmapping application which needs to work offline on iPad (and sync back to base when online). Dropbox seemed to provide the only workable solution.
Users should be able to add point features to the webmap and save them to a text file (geojson) in the offline dropbox folder on iPad.
I have created a dropbox app and set the file to be available offline, but am unable to write/overwrite it offline - online I can make a change in any of iPad/PC/Laptop and almost immediately see the updates to the file (valid geojson).
I am using the following code to write the file and, I guess, the offline issue is with the xhr requests and offline use, but I don't know what else to use - any advice would be appreciated. Cheers.
// ** in function called by button click in web map
var data = pt.toGeoJSON();
var convertedData = JSON.stringify(data);
var xhr = new XMLHttpRequest();
xhr.upload.onprogress = function(evt) {
var percentComplete = parseInt(100.0 * evt.loaded / evt.total);
// Upload in progress. Do something here with the percent complete.
};
xhr.onload = function() {
if (xhr.status === 200) {
var fileInfo = JSON.parse(xhr.response);
// Upload succeeded. Do something here with the file info.
}
else {
var errorMessage = xhr.response || 'Unable to upload file';
// Upload failed. Do something here with the error.
}
};
xhr.open('POST', 'https://content.dropboxapi.com/2/files/upload');
xhr.setRequestHeader('Authorization', 'Bearer xyz');
xhr.setRequestHeader('Content-Type', 'application/octet-stream');
xhr.setRequestHeader('Dropbox-API-Arg', JSON.stringify({
path: '/DBXTest.txt',
mode: 'overwrite',
//mode: 'add',
autorename: true,
mute: false
}));
xhr.send(convertedData);
The Dropbox API and JavaScript SDK do not offer native offline functionality unfortunately, but I'll pass this along as a feature request.
In order to make a Dropbox API call, such as to upload files using /2/files/upload as you have in your code, the client does need an active Internet connection. We have an official JavaScript SDK you can use, but it doesn't offer the ability to automatically queue up API calls offline. If you need offline support, you'll need to implement that in your own code. Apologies I don't have better news for you!
Many thanks Greg,
I've been looking at (potential) solutions to this issue for a month or more - so many dead ends and red herrings - many to do with iOS/iPad (solution works fine on Windows).
I believe I have tried every JS library out there (often more than once), but am still unable to get my web portal to save a text file (GeoJSON) on the iPad - apart from displaying the text in a browser window, which the client doesn't want.
I thought dropbox might prove to be my salvation - especially with the automatic sync to base - but it appears not.
It would be good to see this capability in future releases.
Cheers,
Mark
Hi there!
If you need more help you can view your support options (expected response time for a ticket is 24 hours), or contact us on X or Facebook.
For more info on available support options for your Dropbox plan, see this article.
If you found the answer to your question in this Community thread, please 'like' the post to say thanks and to let us know it was useful!