Need to see if your shared folder is taking up space on your dropbox 👨💻? Find out how to check here.
Forum Discussion
iwansyahp
8 years agoExplorer | Level 3
Google App Engine and Java SDK GetTemporaryLink Error
I use Dropbox to save my application's user uploaded files. The upload part is running well. But When I try to get temporary link to my user's (not Dropbox user) files. I can't get the temporary link...
Greg-DB
Dropbox Community Moderator
8 years agoI'm afraid I don't follow. The method would either return a result or raise an exception. Please double check the actual result.
Also, can you share the relevant code and steps to reproduce the issue?
Also, can you share the relevant code and steps to reproduce the issue?
iwansyahp
8 years agoExplorer | Level 3
This is my actual code.
public String unduhBerkas(String path)
throws GetTemporaryLinkErrorException, DbxException{
DbxRequestConfig config = DbxRequestConfig.newBuilder("My_App/1.0")
.withHttpRequestor(new GoogleAppEngineRequestor())
.withAutoRetryEnabled(100) // maksimal cobalagi jika gagal membuat request
.build();
DbxClientV2 client = new DbxClientV2(config, ACCESS_TOKEN);
GetTemporaryLinkResult temporaryLink = client.files().getTemporaryLink(path);
this.link = temporaryLink.getLink();
if (this.link.equals("")){
Date date = new Date();
// ambil 4 jam dari sekarang
Date timeLinkExpiresAt = addMinutesToDate(240, date);
SharedLinkSettings sharedLinkSettings = SharedLinkSettings.newBuilder()
.withExpires(timeLinkExpiresAt)
.build();
SharedLinkMetadata sharedLink = client.sharing().createSharedLinkWithSettings(path, sharedLinkSettings);
this.link = sharedLink.getUrl();
// ganti ujung URL dari dl=0 menjadi dl=1 agar bisa didownload
if (this.link.endsWith("0")){
this.link = this.link.substring(0, this.link.length()-1) + "1";
}
}
return link;
}
- Greg-DB8 years ago
Dropbox Community Moderator
I don't see any obvious issues with that. Can you add some logging or connect a debugger to check the actual return value from getTemporaryLink, or any raised exception?- iwansyahp8 years agoExplorer | Level 3
This is the response I got, Another problem I found is response of API is inconsistent for same files (folders), Sometime I got 200, and sometimes 409 HTTPS Status Codes.
This is the screenshot of request timeline.
Dropbox API Error Logging
- Greg-DB8 years ago
Dropbox Community Moderator
The 200 or 409 are just some possible status codes, and only indicate success/failure at a high level. The response body would contain more specific success or error information, but your screenshot doesn't include it unfortunately.
The SDK reads the response body and converts it to the native return type or exception, respectively, though. For example, if there is nothing found at the specific path, the response would be a 409 with some JSON indicating the issue in the response body, converted into a native exception by the SDK.
Please check what output or exception you're getting from the method. For instance, here's an example of handling a few different exceptions. The getTemporaryLink method throws GetTemporaryLinkErrorException.
About Dropbox API Support & Feedback
Find help with the Dropbox API from other developers.
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!