4

I created a simple iOS test app that creates a file locally and uploads this to the associated dropbox share. My objective is to keep updating this file (overwriting it) based on certain events (button press). The contents of the file is simply the current date & time at the time of the event.

When I first run the app, the upload works every time - if the file existed before it is overwritten (updated) using this:

NSString * destination = @"/";
NSString * rev = [_fileDetailsDict objectForKey:[destination stringByAppendingString:fileName] ];
[[self restClient] uploadFile:fileName toPath:destination withParentRev:rev fromPath:fullPath];

Whereby _fileDetailsDict holds the parent rev, needed to overwrite the file and not create a copy.

The trouble is that if the application attempts to update the file a second time (based on me pressing a button), I always get a "conflicted copy" error response from dropbox. If instead, I restart my app, the update happens fine again. At first I thought this to be a timing problem but even if I wait several minutes to press the button this problem persists.

It "feels" as if I didn't close out the upload to dropbox somehow. What am I missing?

Yohst
  • 1,671
  • 18
  • 37
  • 2
    Uploading the file the first time results in a new rev. To be able to do the second upload, you need to specify this new parent rev. – rmaddy Apr 27 '13 at 15:51
  • Yeah, I thought of that. So right after the call to uploadFile: I stuck in a call to: [[self restClient] loadMetadata:@"/"]; which I capture the results of in the loadedMetadata: delegate method, updating the rev property. Made no difference. Should there be some waiting time between uploadFile: and loadMetadata: ? – Yohst Apr 27 '13 at 17:43
  • 1
    Oh, figured it out - I didn't fully appreciate that these are all async methods. In stead of updating the rev right after the uploadFile: method, I should have captured the new rev in the uploadedFile: delegate method which gets fired when all the action is completed. Thanks for setting me straight rmaddy. – Yohst Apr 27 '13 at 17:51

1 Answers1

0

Try passing nil to the withParentRev parameter. I guess you know the usage of the files .rev parameter, I tried passing nil to the parameter and it created a new file every time (not a copy).

May be this would be much help for you. I referred this when I had a similar problem.

Satheesh
  • 10,998
  • 6
  • 50
  • 93
  • I don't want a copy, I need to update (overwrite) the original file. Passing nil would give me: my file.txt my file (1).txt my file (2).txt etc… I simply want "my file.txt" to be updated continuously. – Yohst Apr 27 '13 at 17:38