0

Does the Dropbox Sync API allow for copying directories or files from Dropbox into the app sandbox directories?

I was excited to use the Dropbox Sync API and use Dropbox to manage media assets between my OS X machine and an iPad running my app.

I integrated the Sync API pretty quickly and am able to open files and save them in to Dropbox again.

Because my app is already set up with many many calls to dynamically load media assets, it would add unnecessary complexity to try to open all those assets from the Dropbox filesystem. My intention was to use the Sync API to determine if there are updated assets and then copy them in to one of my application directories.

But it seems that nearly all the objects returned using the Sync API are DBObjects, and I can't perform normal NSFilesystem file operations such as copy. Also the DBObjects seem to have no copy functions themselves.

Is there any way to do this without resorting to the CorecAPI?

Example, for an arbitrary file type called story

//get a list of stories and put them in an array
    DBPath *storyPathDB = [[DBPath root] childPath:@"/storyBundlesDB"];
    NSArray *listOfStoriesDB = [[DBFilesystem sharedFilesystem] listFolder:storyPathDB error:nil];
    for (DBFileInfo *story in listOfStoriesDB)
    {
        //now I can list out the path of my stories, but that's about it...
        DBPath *storyPath = story.path;
        NSLog(@"%@",storyPath.stringValue);
        //How can I treat these stories whether they are directories or .mov, .png, and copy them to my app directory? 
    }

I saw this question here Data syncing with DropBox API and iOS where people suggested using the SyncAPI for exactly this purpose, but it seems as if noone on that thread had actually tried it.

Community
  • 1
  • 1
  • You may see my answer here: http://stackoverflow.com/a/19697998/88597 using Dropbox Sync API – ohho Oct 31 '13 at 03:36

1 Answers1

0

You could use readData to read the contents of the file and then write it to another location, if you can't directly use the DBFile objects.

Note that if you want to get notifications when a file (in Dropbox) changes, you'll need to hold that file open. Essentially, files are only updated when you hold the file open, get a notification that there's newer content available, and then call update.

user94559
  • 59,196
  • 6
  • 103
  • 103