Search code examples
macosdropbox

Programmatically trigger online-only Dropbox file download on macOS


I often write console-based apps and scripts, on macOS especially. They unable to access the zero-length contents of "online-only" Dropbox placeholder files and I have manually sync local copies through the UI.

Is there a Mac file API - or even a console command that runs in the background - I can programmatically access that will trigger or force an online-only Dropbox file to download a local copy?

I've tried console commands such as cat, C API's such as fopen(), and Mac/Cocoa API's such as NSFileManager, NSFileHandle, and [NSData dataWithContentsOfFile], without success. The placeholder files remain at zero bytes.


Solution

  • Unfortunately Dropbox doesn't offer an interface for programmatically managing this setting, such as to set a file to "offline", but I'll pass this along as a feature request. I can't promise if or when that might be implemented though.

    Online-only files should be automatically downloaded when opened though, except for some issues that may affect users on macOS. That's not part of the API itself though, so if that's not working as expected for you, you may want to contact support.

    Alternatively, as Mark noted in the comments, you can use the Dropbox API instead, to download file data directly. For example, you can use the /2/files/download endpoint, or the corresponding files_download method in the official Dropbox Python SDK.