Dropbox API Creating a shared link for a file using the Dropbox Java library


Example

This uses the Dropbox Java SDK to create a shared link for a file at the Dropbox path /test.txt:

try {
    SharedLinkMetadata sharedLinkMetadata = client.sharing().createSharedLinkWithSettings("/test.txt");
    System.out.println(sharedLinkMetadata.getUrl());
} catch (CreateSharedLinkWithSettingsErrorException ex) {
    System.out.println(ex);
} catch (DbxException ex) {
    System.out.println(ex);
}

This assumes client is a pre-existing and authorized DbxClientV2 object, and does some basic exception handling to print the output.