1. What is vfs-dbx ?
    1. Project page
    2. Quickstart
    3. Supported Capabilities
    4. Authentication
    5. Third party libraries
    6. Change History

What is vfs-dbx ?

vfs-dbx is a java library which enables one to access dropbox files using the apache commons vfs library.

Project page

The project is hosted on sourceforge. Here you will find the latest downloads,  issue tracker and discussion board.

Please use the help discussion board for support.
Please use the general discussion board for sharing ideas or for general comments.

Quickstart

1. Go to the dropbox developer page, create a new app, and copy the app key and secret.
2. Download the vfs-dbx project
3. In the vfs-dbx project folder edit the json file app.auth.
4. Enter the app key and secret into the file and save it.
5. Execute auth.bat or auth.sh
6. Invoke the displayed URL (link) in an internet browser
7. If required login to dropbox and click "Allow"
8. Enter the authorization code into the auth.bat application.
9 The application creates the file token.auth and terminates.


public class QuickStart
{
    public static void main(String[] args) throws Exception
    {
        ((DefaultFileSystemManager)VFS.getManager()).addProvider("dbx", new DropboxFileProvider());        (1)
        FileObject fo = VFS.getManager().resolveFile("dbx:/");                                                                                (2)
        System.out.println("found root file: "+fo);
     }
}


(1) define "dbx" as dropbox URL schema

(2) invoke vfs methods

The above program will print the root folder of your application.

Supported Capabilities

File System Directory Contents Authentication Read Write Create/Delete Random Version Rename Append
dbx Yes Yes Yes Yes Yes No No Yes   No 

Other capabilities may be added in the future.

Authentication

Per default authentification is done through files:

The authenticator first searches for the file token.auth and tries to authenticate using this file.
If the file does not exist or if the authentification fails the authenticator searches for the file app.auth.
The user is displayed the authentication URL and asked to provide the authentication code.
The code is stored in the file token.auth.

Per default the files are stored in the working dir of the application.
The java system properties vfs.dbx.app.auth, vfs.dbx.token.auth allow to override the default file names.

The authentication can also be done programmatically:



public class AuthenticationExample
{
    public static void main(String[] args) throws Exception
    {
        DropboxAuthenticator auth = new DropboxAuthenticator("accessToken");                                                      (1)
        FileSystemOptions opts = new FileSystemOptions();
        DefaultFileSystemConfigBuilder.getInstance().setUserAuthenticator(opts, auth);        
        ((DefaultFileSystemManager)VFS.getManager()).addProvider("dbx", new DropboxFileProvider());             (2)
        FileObject fo = VFS.getManager().resolveFile("dbx:/", opts);                                                                            (3)
        System.out.println("root folder "+fo);
    }
}



(1) create an authenticator given an access token (or application key and secret)
(2) associate the dbx schema with the dropbox file provider
(3) invoke vfs methods using the authenticator

Third party libraries


Change History

can be found here