public String uploadFile(List<File> list, String dropboxPath) throws Exception {
StringBuilder sb = new StringBuilder("");
for (File f : list) {
try (FileInputStream in = new FileInputStream(f)) {
UploadProgress prog = new UploadProgress(f);
FileMetadata metadata = client.files().uploadBuilder(dropboxPath + f.getName()).withMode(WriteMode.ADD)
.withClientModified(new Date(f.lastModified()))
.uploadAndFinish(in, prog);
System.out.println();
System.out.println(f.getName() + "matadata : " + metadata.toStringMultiline());
prog.done();
sb.append(client.sharing().createSharedLinkWithSettings(dropboxPath + f.getName()).getUrl());
sb.append(System.lineSeparator());
} catch (Exception ex) {
System.out.println();
System.out.println("Failed to upload file \"" + f.getName() + "\": " + ex.getMessage());
System.out.println();
throw ex;
}
}
return sb.toString();
}
I've made a method that uploads files and retrieve download links of them.
my question is :
1. I sometimes got this Exception message :
Exception in thread "main" com.dropbox.core.v2.sharing.CreateSharedLinkWithSettingsErrorException: Exception in 2/sharing/create_shared_link_with_settings: {".tag":"shared_link_already_exists","shared_link_already_exists": ... and so on
probably because I used createSharedLinkWithSettings method multiple times testing.
So. How can I grab Existing download link without trying to recreate them?
2. When I click one of the created link to a pdf file, I got a viewer, not a download page.
Is there any way to get a link that gives me a direct download page?