I have the requirement to allow the user to be able to backup all of their files. I have 3 locations I store files in my app. One is to store the files locally on the device. Second is to store the files in iCloud Drive in the Mobile Documents folder (which is just another folder in the file system), and third, in Dropbox.
In the local and iCloud Drive situations, I can simply create a zip file that stores all of the files to be backed up.
How would I go about doing that with Dropbox since there's no way of using regular NSFileManager calls on any files in Dropbox with the Sync API? Does it mean that every file I want to add to my zip file I have to first open a DBFile, read it into an NSData, then write it out to the local file system, then add that file to my zip archive? I can imagine that will perform very badly. Also, my directory structure can contain any number of folders and sub-folders. So this presents a bit of a problem for me I think when using the Sync API.
Do you have any recommendations on how to handle this situation?
Yes, you'd need to open each file (to download it or access a cached copy), and then add each to your zip file individually.
I think the difference that's surprising you as compared to iCloud Drive (from your description) is that the Sync API doesn't proactively maintain local copies of files in Dropbox. It does cache them once they're accessed (on a MRU basis), in which case accessing the file should be quite fast. If the files aren't already in the local cache, though, it will take time to download them.
Re: How to backup files stored in Dropbox when using Sync API?
Yes, I'm realizing that I'm going to have to just sync to a local cache of files so it operates a bit more like iCloud Drive. I was just trying to reduce the disk space required. But I think I can reduce the Dropbox cache size to accomplish that and still be able to access my files using NSFileManager calls, but interact with the Dropbox sync API for specific things, such as deleting files. It'll be much easier to make my backups then.
We love to learn from the educators who use Dropbox. Whether you teach kids, teens, adults or a combination of all three, we want to know what apps and integrations you use with Dropbox to help with teaching. Which of the ones below is your favorite, or most used tool?