Learn how to make the most out of the Dropbox Community here 💙!
Forum Discussion
Baki A.
9 years agoNew member | Level 1
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());
}
}
1 Reply
Sort By
- Greg-DB
Dropbox Staff
[Cross-linking for reference: https://stackoverflow.com/questions/39344740/dropbox-java-api-upload-file ]
It looks like you've already found the methods for uploading and creating shared links. Is your code not working? If not, what error are you getting?
About Dropbox API Support & Feedback
Find help with the Dropbox API from other developers.5,984 PostsLatest Activity: 2 days ago
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!