Your workflow is unique 👨💻 - tell us how you use Dropbox 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
- Greg-DB9 years ago
Dropbox Community Moderator
[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 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!