9

I have an iOS app which stores data in the local directory. I'd like to be able to sync this data between multiple devices running my app. Currently this is using core data, but I'd expect to have to change to some text-based file storage system to make syncing easier.

I was expecting the DropBox API would make this nice and easy, and that I could tell the API to simply sync the contents of my data folder on startup/save. However it seems the DropBox API is nothing more than a glorified way of uploading and downloading files.

Am I wrong on this assumption? Can the DropBox API actually make it easy to keep a folder full of text files in sync? If not, is there some other service or even advice you can give? Syncing is hard - I was hoping DropBox would make it easier.

2
  • Hi there. I was wondering if you were every successful in getting a simple DropBox sync to work. I'm confronted with the same frustrating problem at the moment and started a new question here in the hope of getting some sample code to illustrate the whole sync process. stackoverflow.com/questions/5950168/…
    – n.evermind
    Commented May 10, 2011 at 12:52
  • I have up on it fairly quickly as it was evident it couldn't do what I was after. The API is more so you can access a users DB account, not for providing sync services. Commented May 10, 2011 at 22:48

5 Answers 5

7

Using /metadata, getting information about the contents of a folder couldn't be easier. All you need to do is check the modified date, and if it's different than yours locally, perform the appropriate action. It will also give you the metadata for any file contents, so you can pick out which files need to be uploaded / downloaded / added / removed as necessary.

Any more functionality than this would be very application-dependent; you can decide for yourself when and how you want to deal with differing files.

Dropbox API Documentation

9
  • Thanks Andy, I guess I glossed over the metadata call, where as it's actually pretty important! How does this approach sound - make the call to metadata, update any files which have a different modified date, download any files that are new, upload any files that have been updated, then upload any files that are new. Commented Jan 27, 2011 at 2:44
  • Hmm, but how to handle files that have been deleted from the directory? How would I know if a file is new and needs to be uploaded, or has been deleted on another device and needs to be removed? Commented Jan 27, 2011 at 2:47
  • Seems like the way to go to me - it's up to you as to how often you want to be hitting that API. There are limits (5000 requests per day per access token and 300MB / file) that will likely not come into play for a mobile device, so you should be fine on that front. Commented Jan 27, 2011 at 2:49
  • In the case of files being deleted, I think the only way to go would be to have a text file with a list of changes or something along those lines... "-filename nameofservice" or "+filename nameofservice" to indicate whether or not the current service should be adding to the remote store or removing from its local store. Commented Jan 27, 2011 at 2:52
  • 1
    Thanks - still seems like a lot of manual work. I would have thought the main point of the API is to provide a simple syncing service, eg. "sync this folder now". Commented Jan 27, 2011 at 2:59
3

Won't repeat since Andy has answered your question, thought you may also find this tutorial helpful:

http://www.nanaimostudio.com/blog/2011/1/20/how-to-synchronize-your-app-data-using-dropbox-api.html

2
  • I'm getting the following error when I build the code in the Nanaimo blog. These errors occur in loadedMetadata function: request for member 'contents' in something not a structure or union AND request for member 'path' in something not a structure or union and also there is a problem with the addObject statement(Expression does not have a valid object type). Please help
    – Namratha
    Commented May 5, 2011 at 7:11
  • Can you see pictures in this tutorial?
    – rjobidon
    Commented Nov 13, 2012 at 12:45
3

Check out the new DropBox Sync API.

1
  • Future readers: Dropbox deprecated that API several years later. Commented Aug 17, 2020 at 23:20
2

As ohho mentioned, there's the DropBox Sync API available now which I think will do what you mentioned (I haven't tried it personally, as I integrated support for Dropbox in my app using the earlier SDK, before this came along). This will probably suffice if you're just working with dropbox.

In my case I've been starting to add support for additional online storage ("Cloud") services to my app, and am finding that it's somewhat challenging to deal with the differences between them in how they handle various concepts like authentication, version, naming etc. For example Dropbox's API references files according to their path, whereas Box's API references files according to their file id (which has an associated path, but I believe remains the same if the file is moved). Then there's also all the issues of conflict resolution (aka merging) which come about when multiple clients try and sync conflicting changes to the server.

I've actually been recently considering starting an open source project to develop a library which can connect to all the major services, and provide an abstraction layer that papers over their differences, and also handles the syncing process for you. I've actually got some code already (which I haven't publicly released to date) but could use that to get the project started.

Would this be of use to you? Would you (or any others) be willing to participate in such an effort?

(note to mods: I realise this may be deviating somewhat off-topic - sorry about that. If you can recommend a more suitable forum to discuss this I'd be happy to take the conversation there).

0

There is a RSS feed that can be limited to one of the shared folders but it kind of filters events to keep volumes low.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.