1

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.

Undistraction
  • 42,754
  • 56
  • 195
  • 331

2 Answers2

1

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.

vgoff
  • 10,980
  • 3
  • 38
  • 56
  • Thanks. Could you give me a bit more context. Which API are you referring to? – Undistraction Oct 29 '13 at 10:27
  • I am using it directly from the dropbox tool in the shell. There could be a dropbox gem available though to do the same thing. I haven't had to do so with such frequency or volume to worry about it, so I just have so far done so with the command line dropbox tool. – vgoff Oct 29 '13 at 10:32
  • Turns out the Dropbox CLI isn't available on OSX. – Undistraction Oct 29 '13 at 11:28
  • The gem you reference is poorly maintained and buggy, but the Dropbox Ruby API does the job nicely. – Undistraction Oct 29 '13 at 20:57
  • Yeah, I can't attest to the suitability of the gem, and never stated so, it was not an advertisement or endorsement of the gem. It was just a gem that you could look at for the code samples. Reading the README and the code is what I was referring to, not the gem itself. I had not evaluated any gems for this, as stated, I do so using a CLI tool. – vgoff Oct 30 '13 at 02:41
  • No worries. Was not calling you out. Just adding a comment so anyone stumbling across this knows not to bother with it. – Undistraction Oct 30 '13 at 06:32
  • Or hopefully maintain it. :) – vgoff Oct 30 '13 at 09:03
1

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.)

user94559
  • 59,196
  • 6
  • 103
  • 103