How can I monitor the sync status of a file in Dropbox?
I have a Rake task that involves adding a file to my Dropbox/public folder. I need to monitor its sync status so I can call another Rake task once it is synced and publicly available.
How can I monitor the sync status of a file in Dropbox?
I have a Rake task that involves adding a file to my Dropbox/public folder. I need to monitor its sync status so I can call another Rake task once it is synced and publicly available.
You can use the filestatus
option on the dropbox
command.
Once the command returns "up to date" in the string, it should be synchronized.
There is a gem for this as well. The Readme can get you started.
Are you uploading the file via the Dropbox API, or by copying it into the local Dropbox folder? If via the API, the file will be available immediately once the call returns.
If you're copying to the local file system and the target is a public folder, you could poll the URL of the file (i.e. dl.dropboxusercontent.com/u/<user id>/<path>
). Once it returns a 200 (instead of a 404), it means the file exists in Dropbox. (If you're updating an existing file, you may want to look at the etag
header to verify that the file changed.)