Dropbox API Support & Feedback
Find help with the Dropbox API from other developers.
Hi,
I am buildng an app in Java Dropbox API V2 that would display for each file or folder a link only if the owner has created a link for it.
The application is this application screenshot.
I'll explain better now.
I know it's possible to create from the dropbox.com website a link for any of the items create a link screenshot.
without specifying any email address to who I am sharing the file with anyone can view screenshot.
I noticed all these items where a link have been created are in the links section link section screenshot.
My questions are:
1)Since for a file or folder a link might have been created or not from the owner, how can I discover for each file or folder if a link does exist ?
2)In case a link does exist, how can I get it via API?
In case it does not exist I don't want to create one.
I hope my questions make sense.
I thank you in advance for your hard work.
You can use /sharing/list_shared_links, passing the path to the file. If you only want links to that exact path (and not parent folders), use direct_only=true.
okay I realized only today all my links are expired.
I put together something like this but it is incomplete..
private List<SharedLinkMetadata> retrieveAllSharedLinks(DbxClientV2 client ) throws DbxException
{
List<SharedLinkMetadata> result = new ArrayList<SharedLinkMetadata>();
ListSharedLinksResult resultList = client.sharing().listSharedLinksBuilder().withPath(").withDirectOnly(true).start();
while (true) {
for (SharedLinkMetadata sharedLinkMetadata : resultList.getLinks()) {
result.add(sharedLinkMetadata);
}
if (!resultList.getHasMore()) {
break;
}
//resultList = client.sharing().listSharedLinks(). I don't know what to put in this line here
}
return result;
}
It misses the pagination since I don't know how to get the others...
I looked the whole Internet but I couldn't get this snippet of code.
I bet it should be something similar to
resultList = client.files().listFolderContinue(resultList.getCursor());
but it's for sharedlinks.
Will you give me further help? I beg you...
Untested, but I believe it's just this:
client.sharing().listSharedLinksBuilder()
.withPath(")
.withDirectOnly(true)
.withCursor(resultList.getCursor())
.start();
See the documentation: https://www.dropbox.com/developers/documentation/http/documentation#sharing-list_shared_links.
Also, you may want to drop the .withPath(") in both calls if you're just trying to search for all links.
Hi,
I gave up with getting the links all at once and I fetch the shared links once per time.
I put back the .withPath(path) and I passed the path wanted without any cycle to get the others.
It's too difficult to figure out the pagination to get all the links at once without a template snippet in at least one of the languages among C, Python or Java or another.
Thanks for your time again.
Hi there!
If you need more help you can view your support options (expected response time for a 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!