cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Announcements
Want to learn some quick and useful tips to make your day easier? Check out how Calvin uses Replay to get feedback from other teams at Dropbox here.

Dropbox API Support & Feedback

Find help with the Dropbox API from other developers.

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

I need a php/js based webapp that syncs files between it's server and it's dropbox app folder

I need a php/js based webapp that syncs files between it's server and it's dropbox app folder

ivan006
Helpful | Level 6

It only needs to be a one way sync (from dropbox to the server) Any recommended libraries/tutorials/endpoints to do this?

[ same q dif platform https://stackoverflow.com/questions/61755432/dropbox-server-integration-php-library ]

6 Replies 6

Greg-DB
Dropbox Staff

Dropbox doesn't offer a pre-built library or tutorial for a sync client, but I'll pass this along as a feature request. I can't promise if or when that might be implemented though. 

 

The Dropbox API does offer the ability to list, upload, and download files programmatically though, among other operations, so you can implement whatever kind of syncing you need in your app's code. 

 

For example, to list files and folders:

To download files:

To upload files:

 

Those are links to the documentation for the HTTPS endpoints themselves, but we recommend using one of the official SDKs if possible. Those have corresponding native methods for the HTTPS endpoints. Dropbox does offer an official JavaScript SDK, but not one for PHP. For PHP, you could use the endpoints as above, or a third party library, such as the ones listed here.

ivan006
Helpful | Level 6

to further the quality of my question - I hope this helps:

Q: describe the problem and what has been done so far to solve it

A: the problem is im not sure what mechanism to use to determine changes to dropbox app folder, maybe webhooks?

Greg-DB
Dropbox Staff

Webhooks can tell you when something changed, but not what changed. To find out what changed, you would then use the list_folder endpoints. In addition to letting you list the contents, the list_folder endpoints also enable you to keep track of new changes over time:

I also recommend reviewing the Content Access Guide for some more information.

ivan006
Helpful | Level 6

Ok so how do i find out what changed? is it a file property?
please dont tell me ur refering to the date modified property? unless that could work as i could say "if it has changed in the last five minutes after the webhook fired then download it"...

Side note: Is there a statergy for this requirement or am i the only person in the world who has ever considered such things? lol

Greg-DB
Dropbox Staff

You can store the last received cursor from /2/files/list_folder or /2/files/list_folder/continue and then call back later to /2/files/list_folder/continue with that cursor. The response will contain entries for the changes since you last called. Check out the /2/files/list_folder documentation for more information on how to process these entries.

 

Exactly how you write your code will depend on what exactly you need your app to do of course, but I imagine other people have implemented things like this. Perhaps others on the forum can offer some insight on their experience when doing so if they see this thread.

ivan006
Helpful | Level 6

Endpoints to use:

- Initial sync: download to zip (then extract)
- Thereafter syncs:
  - Check for changes trigger: Use a webhook
  - Check for changes: Use a cursor

Need more support?
Who's talking

Top contributors to this post

  • User avatar
    ivan006 Helpful | Level 6
  • User avatar
    Greg-DB Dropbox Staff
What do Dropbox user levels mean?