Reputation: 12659
I'm having trouble implementing a dropbox backup to my app. I wan't the every next backup to overwrite previous one.
I tried this first:
newEntry = mDBApi.putFile("/file.bak", inputStream, file.length(), null, null);
It was creating test.bak and then test.bak(1) test.bak(2) and so on...
then I tried to save the revision id of the first file, and then pass it to every upload.
newEntry = mDBApi.putFile("/file.bak", inputStream, file.length(), revision, null);
I get file.bak and then file.bak (conflicted copy.... ) and so on
What am I doing wrong? Dropbox documentation says that the conflicted copy appears when 2 users try to upload the same file on the same time, but it's not happening right here
EDIT: I can workaround it by deleting file 1st, but that doesn't sound too proffesional
Upvotes: 2
Views: 3727
Reputation: 1267
Try this:
try {
DropboxAPI.Entry newEntry = mDBApi.putFileOverwrite("/file.bak", inputStream, file.length(), null);
} catch (DropboxUnlinkedException e) {
Log.e("DbExampleLog", "User has unlinked.");
} catch (DropboxException e) {
Log.e("DbExampleLog", "Something went wrong while uploading.");
}
Upvotes: 1
Reputation: 7269
Just take a look at the Dropbox API.
It provides a method for overwriting an existing file (with the same filename): putFileOverwrite
Or, if you want to be able to cancel the upload, create a putFileOverwriteRequest and kick it off by calling upload()
.
Upvotes: 5