Your workflow is unique 👨‍💻 -  tell us how you use Dropbox here.

Forum Discussion

Holger K.'s avatar
Holger K.
New member | Level 2
9 years ago

Sharable link to file using Java API v2

Hello, I am able to upload a  file with Java API v2:

try (InputStream inputStream = new FileInputStream(localFile)) {
return mDbxClient.files().uploadBuilder(remoteFolderPath + "/" + remoteFileName)
.withMode(WriteMode.OVERWRITE)
.uploadAndFinish(inputStream);
} catch (DbxException | IOException e) {
mException = e;
}

How can I get a sharable link to this file?

Thanks!

5 Replies

Replies have been turned off for this discussion
  • Holger K.'s avatar
    Holger K.
    New member | Level 2
    9 years ago

    Thanks, but the resulting link is not public, it requires to login

    SharedLinkMetadata slm = mDbxClient.sharing().createSharedLinkWithSettings(remoteFolderPath + "/" + remoteFileName, SharedLinkSettings.newBuilder().withRequestedVisibility(RequestedVisibility.PUBLIC).build());
    String url = slm.getUrl();

  • Greg-DB's avatar
    Greg-DB
    Icon for Dropbox Community Moderator rankDropbox Community Moderator
    9 years ago

    What is the the SharedLinkMetadata.LinkPermissions.ResolvedVisibility on the resulting link metadata (your slm variable)? It can be different than the requested visibility, per the documentation:

    "The current visibility of the link after considering the shared links policies of the the team (in case the link's owner is part of a team) and the shared folder (in case the linked file is part of a shared folder)."

  • Holger K.'s avatar
    Holger K.
    New member | Level 2
    9 years ago

    The resolved visibility is PUBLIC, but today it seems to work.
    I did not change my code, so this is pretty odd.

    Anyways I have one more question about this. The link that is returned ends with dl=0.

    Is there some parameter that returns a link ending with dl=1

  • Greg-DB's avatar
    Greg-DB
    Icon for Dropbox Community Moderator rankDropbox Community Moderator
    9 years ago

    No, the API doesn't provide a way for controlling that, but you can parse the URL and change it on the client-side. There's information about these parameters here:

    https://www.dropbox.com/help/201

About Dropbox API Support and Feedback

Node avatar for Dropbox API Support and Feedback
Get help with the Dropbox API from fellow developers and experts.

The Dropbox Community team is active from Monday to Friday. We try to respond to you as soon as we can, usually within 2 hours.

If you need more help you can view your support options (expected response time for an email or ticket is 24 hours), or contact us on X, Facebook or Instagram.

For more info on available support options for your Dropbox plan, see this article.

If you found the answer to your question in this Community thread, please 'like' the post to say thanks and to let us know it was useful!