Need to see if your shared folder is taking up space on your dropbox 👨💻? Find out how to check here.
Forum Discussion
eliotcole
6 years agoExplorer | Level 4
Programmatically Process Shared Link Folders and Sub-Folders and Their Contents
Well I'm still at a loss.
I have the shared link to a folder that I need to check on a daily schedule to see if there's new files. The logic of which is all fine, but I just can't access anything below the initial shared link programatically.
Really all I need to get is the URL for any subfolder ... but I'll be damned if there's an API call that will supply that information.
- I have tried with the API token provided by the DB Dev Docs (auto).
- I have tried with my own token in place of that (to make the API call come from my account).
- I have tried all of the following and none can penetrate the barrier that is the second level of folders:
- get_shared_link_metadata
- get_folder_metadata
- list_received_files
- list_folder
- list_folders
I have access to the shared link, I have access to all the (3) subfolders.
One thing I note is that the URL changes once I enter the subfolder of the main shared link, and I'm unable to programattically
get that to just launch either a new get_shared_link_metadata on the new URL, or list_folder to get its contents. So if we had a primary shared link of:
https://www.dropbox.com/sh/aaa/bbb/
Let's say that has a subfolder called "john", I can't resolve that via the API because the URL to the john folder is not:
https://www.dropbox.com/sh/aaa/bbb/john
The link, instead, is:
https://www.dropbox.com/sh/aaa/ccc/john
A quick breakdown of how I would desire this to work:
Stage 1:
get_shared_link_metadata ---> list_folder
This works, and provides me with the contents of the shared folder, and the names and IDs of the subfolders.
Stage 2:
UNKNOWN ---> list_folder
This is the repeated stage (for each of the 3 subfolders), the UNKNOWN represents what I don't know, that should essentially be the equivalent of the get_shared_link_metadata ... except I don't have the right link for the subfolders, because they are changed each time.
16 Replies
Replies have been turned off for this discussion
- Greg-DB6 years ago
Dropbox Community Moderator
Unfortunately, the Dropbox API doesn't offer a way to copy from a shared link into the connected Dropbox account via the API like this, but I'll pass this along as a feature request as well. I can't promise if/when that might be implemented though.
The /2/files/copy_v2 call (or native method in an SDK) that you're referring to only supports copying files from one location in the connected account to another location in the same account. It doesn't support using a shared link as the source.
You could download the files, using /2/sharing/get_shared_link_file, and then upload them to the account, e.g., using /2/files/upload, but that would be comparatively inefficient of course.
- eliotcole6 years agoExplorer | Level 4
Cheers, Greg, and thanks for taking it to the developers.
I will say that I've perused a few topics on this, and they've all been at least a year old, so I'm wondering if there's ever actually going to be any real movement with the (Public) Shared Folders/Links. (i'm not saying that in a tone that would indicate an attack on your person, mate ... just ... it seems like it's something that isn't desired for the public to have)
I guess, then, my final question would be what API command would you see as the best use case with regards to a cloud based implementation that may have size limits (let's take the Google API with limits size to 50MB per upload/download).
I would imagine that a "download then upload" won't be the ideal solution for that, would it? Would something like " get_temporary_link " work better. So it would:
- Locate a file ID.
- Generate a temporary link.
Allow that link to be used to directly access the file in question?
To be clear, I'm not stating that in a literal fashion, just using the get_temporary_link as an example, I'm sure there's a more appropriate function to achieve this.
Essentially, once I have identified a file that I would like to copy to another (let's assume an external API to work this out better) then I need to essentially be given a direct link to the file, somehow, to present to the other API. How would I get that link?
----
Would it perhaps be " get_shared_link_file " ?
If so, how would that work with the previously mentioned subfolder issues in that path?
https://content.dropboxapi.com/2/sharing/get_shared_link_file
(I'm about to attempt it, but will try to play it out here, too)
- Greg-DB6 years ago
Dropbox Community Moderator
Right, whenever possible, it's best to avoid unnecessarily uploading/downloading locally, for the sake of reliability and efficiency. Passing a link between two services, if supported, would likely be faster.
In this case, if you need a direct link to a file hosted on Dropbox, the specifics will depend on if the file exists in the Dropbox account you're connected to via the API (i.e., the one for which you have an access token).
If the file is in the connected account, /2/files/get_temporary_link would be a good option. That gives you a direct link to the file content, that you could hand off to the other service. Note that these links only last for four hours.
If the file is not in the connected account though, and say, you just have a shared link, /2/files/get_temporary_link won't work. Instead, this will depend on the shared link you have. If the shared link is already for the file itself, you can modify it for direct access as covered here. However, if the shared link is just for a parent folder, as discussed through this thread, then unfortunately there isn't a good solution. As earlier, the API doesn't offer a way to get a link to just the nested file based on a shared link to the folder that contains it.
- eliotcole6 years agoExplorer | Level 4
Thanks again for coming back on this, mate. Really very much appreciated.
One last question ... how about the whole folder? That is, we know, not nested, and available at root.
Is there any internal reason given as to why the access to Shared Files is so antiquated (sorry) ... or ... let's be honest ... restrictive ... next to the rest of the interface? It seems ... odd. Particularly given the removal of RSS and the way that people use Shared Folders.
----
Also, not for nothing, but then this particular guide should include that Shared Sub-Folders are essentially not accessible via the API:
DBX File Access Guide - Dropbox (the "Non-downloadable files" section)
- Greg-DB6 years ago
Dropbox Community Moderator
Thanks for the feedback! I can't speak to why any particular feature was or wasn't implemented, but we appreciate you taking the time to share this. I'll send it along.
If you have a shared link for a folder and wish to get a direct link to that, you can likewise modify that as documented here. For folders, that will give you a .zip file of the folder.
- Greg-DB5 years ago
Dropbox Community Moderator
Update: The Dropbox API now returns the shared link for the nested item as 'url' when requesting the metadata for that item using the "path" parameter on /2/sharing/get_shared_link_metadata (instead of the original parent link).
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!