Want to know more about How We Use Dash? Check out how Josh Clemm uses Dash here.
Forum Discussion
Arron G.
10 years agoNew member | Level 1
Get all files in shared link loder
I'm looking to use the v2 api to download the contents of a shared folder from a link like this:
https://www.dropbox.com/sh/[some_junk]/[some_other_junk]?dl=0
this link is not necessarily generated by the user authenticating the API call but would be either a public link, or a team link from a team the authenticated user is a member of, or the user would have the password (so my API app would as well) In short this is a link the user COULD access with a browser logged into the authenticating account.
I KNOW that you can add ?dl=1 to the URL to generate a zip. i also know that folders that contain more than 10,000 files or are larger than 1 GB will fail to generate that zip. This is what i'm trying to deal with.
I want to have my app download all of the files in that folder one by one and put them all into the right folder structure on another server so that humans don't need to waste their time doing exactly that.
so, what specific methods do I need to call to list the contents of folders in a shared link? then when there are subfolders there, how do i list THEIR contents?
Thanks.
10 Replies
- Steve M.10 years ago
Dropbox Staff
- Steve M.10 years ago
Dropbox Staff
Oh, actually, I think that get_shared_link_metadata doesn't give you a list of files in a folder...
API v1 has https://www.dropbox.com/developers-v1/core/docs#metadata-link, which should work for you right now, but API v1 is deprecated. I'll check with the team to see if equivalent functionality is available in API v2.
- Arron G.10 years agoNew member | Level 1
Thanks Steve.
That's kind of you. I had a look at both of those endpoints before posting. Unless I'm missing something, I don't think they will help here.
- Greg-DB10 years ago
Dropbox Community Moderator
Steve is correct, this isn't available in API v2, but I'll be sure to pass this along as a feature request.
- Arron G.10 years agoNew member | Level 1
damn. it's almost as if there is a concerted effort to stonewall any attempts i have of getting around the "more than 10,000 files or larger than 1 GB" limit. it's relentlessly frustrating.
- Greg-DB9 years ago
Dropbox Community Moderator
Dropbox API v2 now supports listing the contents of a shared link for a folder. This can be accomplished using the same interface as listing a folder in a connected user's account, via the list_folder functionality. To list the contents of a shared link for a folder, you instead provide the shared link URL in the `shared_link` parameter to list_folder:
https://www.dropbox.com/developers/documentation/http/documentation#files-list_folder
If you're using an official SDK, there will also be a corresponding method for this endpoint:
In the .NET SDK that's available as `ListFolderAsync`:
https://dropbox.github.io/dropbox-sdk-dotnet/html/M_Dropbox_Api_Files_Routes_FilesUserRoutes_ListFolderAsync_1.htm
In the Java SDK that's available via `listFolderBuilder` to get a `ListFolderBuilder` on which you can call `ListFolderBuilder.withSharedLink`:
https://dropbox.github.io/dropbox-sdk-java/api-docs/v3.0.x/com/dropbox/core/v2/files/DbxUserFilesRequests.html#listFolderBuilder-java.lang.String-
https://dropbox.github.io/dropbox-sdk-java/api-docs/v3.0.x/com/dropbox/core/v2/files/ListFolderBuilder.html
https://dropbox.github.io/dropbox-sdk-java/api-docs/v3.0.x/com/dropbox/core/v2/files/ListFolderBuilder.html#withSharedLink-com.dropbox.core.v2.files.SharedLink-
In the JavaScript SDK that's available as `filesListFolder`:
https://dropbox.github.io/dropbox-sdk-js/Dropbox.html#filesListFolder__anchor
In the Python SDK that's available as `files_list_folder`:
https://dropbox-sdk-python.readthedocs.io/en/latest/moduledoc.html#dropbox.dropbox.Dropbox.files_list_folder
In the Swift SDK that's available as `listFolder`:
https://dropbox.github.io/SwiftyDropbox/api-docs/latest/Classes/FilesRoutes.html#/s:13SwiftyDropbox11FilesRoutesC10listFolderAA10RpcRequestCyAA0C0C04ListF16ResultSerializerCAH0if5ErrorK0CGSS4path_Sb9recursiveSb16includeMediaInfoSb0O7DeletedSb0O24HasExplicitSharedMembersSb0O14MountedFolderss6UInt32VSg5limittF
In the Objective-C SDK that's available as `listFolder`:
https://dropbox.github.io/dropbox-sdk-obj-c/api-docs/latest/Classes/DBFILESUserAuthRoutes.html#/c:objc(cs)DBFILESUserAuthRoutes(im)listFolder: - jyotinarang8 years agoExplorer | Level 4
Hi Greg,
I was successful in listing the folders and files from the shared folder, however, I am still having trouble downloading data. The meta-data shows the fields 'path_lower' and 'path_display' to be empty. Could you suggest if I can download the files after listing the entries?
Thanks
Jyoti
- Greg-DB8 years ago
Dropbox Community Moderator
jyotinarang It sounds like you're calling list_folder with a shared link owned by a different user than the one for the access token you're using. In that case, the path values won't be included, but I'll pass this along as a feature request.
That means you'll need to manually build the relative path from the 'name' value. E.g., if the returned metadata entry for the file you want in the root of the folder is "test.txt", you would pass "/test.txt" to get_shared_link_file.
- jyotinarang8 years agoExplorer | Level 4
Thanks Greg for the information. I can see that the function get_shared_link_file() expects a url as parameter. However, this value is not available to me when I get information about the folder. How do I construct a url from just the name?Even with relative paths, I don't see a way to construct the url of the files within the main folder.
Thanks
Jyoti
- Greg-DB8 years ago
Dropbox Community Moderator
jyotinarang Apologies, this thread was about originally about getting the files when working from a shared link for a folder, so I assumed that's the scenario you're working on as well, in which case the 'url' would just be the original shared link for the folder.
If you don't have the link, it sounds like you may be referring to a different scenario. In that case, please open a new thread with the details and code you have so far so we can help with it: https://www.dropboxforum.com/t5/forums/postpage/board-id/101000014
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!