Java library to keep a local folder in sync with a Dropbox account


The Dropbox Java SDK doesn't support continuous synchronization (via Sync API) out of the box (like the Android and iPhone SDK). During my last side project I needed this feature as a Java library and I eventually open sourced the outcome (async-dbx-client) on Github.

asnyc-dbx-client is a client for Dropbox's REST API and supports synchronization of a local folder out of the box. Currently the implementation only support retrieving updates. Sending updates needs to be implemented yet.

The library is based on Akka/ Spray and is written in Scala.

Design goals

  • Tolerant to IO failures (by retrying requests in a given time frame)
  • Full support for the Dropbox API
  • Low-latency to retrieve update notification by using Dropbox's long-polling delta endpoint
  • Gzip compression (not implemented yet)

Examples (Scala)

To get an handle to a Dropbox account, create an instance of a DbxClient and send an authentication request with your OAuth2 token:

import api._
val system = ActorSystem("Dropbox")
val client = system.actorOf(Props[DbxClient])
client ! Authenticate(token) // => Response: Authenticated

Checkout the spec tests for the DbxClient to see it in action.

Retrieving and Applying updates (Syncing a Dropbox folder)

The synchronization process can be kicked-off as easy as the following:

val sync = system.actorOf(DbxSync.props(client, "/tmp/dbx"))

It requests the delta stream and performs all necessary operations when a new delta arrives to apply all changes.

The library transparently tries to recover from IO failures by resending requests, for example when the internet connection was interrupted. This is also valid while downloading files. As the library only requests chunks of a file it can easily recover from an interruption by downloading the failed chunk again. instead of re-downloading the complete file.

For more examples and usages of the API visit the project's home on Github.

Any feedback is highly appreciated.


Marco Rico Gomez is a passionate software developer located in Germany who likes to share his thoughts and experiences about software development and technologies with others.

blog comments powered by Disqus