You might see that the Dropbox Community team have been busy working on some major updates to the Community itself! So, here is some info on what’s changed, what’s staying the same and what you can expect from the Dropbox Community overall.

Forum Discussion

Baki A.'s avatar
Baki A.
New member | Level 1
9 years ago

Dropbox Java Api Upload "Public Folder"

How do I upload a file public and get link ? I am using Dropbox Java core api. Here.

public static void Yukle(File file) throws DbxException, IOException {
FileInputStream fileInputStream = new FileInputStream(file);
InputStream inputStream = fileInputStream;
try (InputStream in = new FileInputStream(file)) {
UploadBuilder metadata = clientV2.files().uploadBuilder("/"+file.getName());
metadata.withMode(WriteMode.OVERWRITE);
metadata.withClientModified(new Date(file.lastModified()));
metadata.withAutorename(false);
metadata.uploadAndFinish(in);
SharedLinkSettings linkSettings = SharedLinkSettings.newBuilder().withRequestedVisibility(RequestedVisibility.PUBLIC).build();
SharedLinkMetadata sharedLinkMetadata = clientV2.sharing().createSharedLinkWithSettings("/"+file.getName(), linkSettings);
System.out.println(sharedLinkMetadata.getUrl());
}
}

 

About Dropbox API Support & Feedback

Node avatar for Dropbox API Support & Feedback

Find help with the Dropbox API from other developers.

5,882 PostsLatest Activity: 3 years ago
325 Following

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 or Facebook.

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!