0

Im trying to overwrite an uploaded file to Dropbox.
Instead of replacing the file, Dropbox keeps adding another conflicted copy, I have got the metadata for the file using

for (DBMetadata *file in metadata.contents) {
            NSLog(@"    %@ metadata %@", file.filename,file.rev);

        }

prints myFile.sqlite metatdata 5372f37f73G

Im uploading the file with:

[restClient uploadFile:@"myFile.sqlite" toPath:@"/Data" withParentRev:@"5372f37f73G" fromPath:filePath];

checked How to overwrite file with parent rev using Dropbox API in iOS?

How to avoid "conflicted copy" when uploading to dropbox from iOS client

dropbox keeps creating conflicted copies ios sdk (core api)

What am I missing here?

Community
  • 1
  • 1
JSA986
  • 5,870
  • 9
  • 45
  • 91
  • Are you sure that's the latest `rev` value? If the file has changed, the `rev` will change, so if you're using an old one, you'll get a conflicted copy. Also, make sure you're getting the right one. I.e., make sure you're not copying the `rev` for a different file or folder. It also looks like you may have a typo in the post here. You have "5372f37f73G" in one spot but "5372f37f73f" in another. – Greg Apr 02 '15 at 17:05
  • Ah, I thought the rev remained a constant value. Yep, typo in that line (typed than pasting that bit). Thanks for the comment, will report back on adjusting my code... – JSA986 Apr 02 '15 at 17:49
  • No problem. The `rev` changes to identify each version of the file in order to avoid race conditions where different clients may overwrite data from the other. You can find more information on how it works here: https://www.dropbox.com/developers/core/docs#files_put – Greg Apr 02 '15 at 17:51
  • Im still not getting this, what is the correct rev value i'm suppose to be using here? How do I get the new rev value rather than the old one? I can access it with the delegate method once loaded but i'm assuming this is the old value as im still getting the same conflicts? – JSA986 Apr 02 '15 at 19:50
  • The "correct" value for `rev` should be the value of the copy you're working on top of, for lack of a better term. The idea is that you pass up the `rev` that you think was the latest version, and if so, the file is overwritten. If not, a conflict is produced, because the version history has effectively branched. So, you in the case where you download a file, modify it, and upload a new version, the `rev` you supply with the upload should be the `rev` at the time of download. – Greg Apr 02 '15 at 19:56
  • If you've updated your app to do this programmatically and are still getting conflicts when they're not expected, update your question with the new code and any output. Or, feel free to open a ticket: https://www.dropbox.com/developers/contact – Greg Apr 02 '15 at 19:58
  • Ive been passing the same value as the previous version all along and still getting conflicts. The value is in the console from the metatdata so I must be using the right value, there are no others. For now i shall delete the existing file the write the new one each time. – JSA986 Apr 02 '15 at 20:12

1 Answers1

0

I was calling the wrong folder for meta data in - (void)restClient:(DBRestClient *)client loadedMetadata:(DBMetadata *)metadata { For anyone else

//Calls all files for your app folder
[self.restClient loadMetadata:@"/"];

//Calls a folder you created within your app folder
[self.restClient loadMetadata:@"/yourfolder"];
JSA986
  • 5,870
  • 9
  • 45
  • 91