You might see that the Dropbox Community team have been busy working on some major updates to the Community itself! So, here is some info on what’s changed, what’s staying the same and what you can expect from the Dropbox Community overall.
Forum Discussion
James_T
4 years agoHelpful | Level 6
Listing files in a folder, and make download links for all files?
I have a private Dropbox.
I have a PHP-driven webpage where i want to list clickable links to some files in a specific folder in my dropbox.
It's simple to list the files on my web page, I just use "files/list_folder/" to get an array of the files in the wanted folder.
But how can I get URLs to download the files, so I can make my list of files clickable?
- ЗдравкоLegendary | Level 20
Hi James_T,
Just use sharing/create_shared_link_with_settings. 😉 Existing links could be enumerated with sharing/list_shared_links.
Hope this helps.
- macribasDropbox Staff
You need to loop that array and create links for each file.
Take a look at the /sharing/create_link_with_settings endpoint.
Alternatively, we provide an embedded component to display the contents of a folder directly in a web page:
https://dropbox.tech/developers/now-available--dropbox-embedder
Maybe that will make your life easier.
- James_THelpful | Level 6
Won't looping through every file and folder and make a ton of share links be very slow?
The embedding solution seems more sensible, but if I understand correctly:
1. The root folder must have a share link created first
2. I have no control over which files and folders are displayed (I can't choose to hide a specific subfolder, or a specific file)
- Greg-DBDropbox Staff
James_T Yes, /2/sharing/create_shared_link_with_settings requires one call per item, so if there's a significant number to process, that would take a significant amount of time. That being the case, you could also consider only creating the shared link on demand, when the user clicks on a specific file. That is, the listed on your file on your page would link to a route on your server, which when accessed, would make the Dropbox API call and then redirect the user to the returned link. (Likewise, /2/files/get_temporary_link would also work here, if you just need a temporary direct download link instead of a shared link.)
Alternatively, if you want to have the user's browser download the file directly, you could use /2/files/download on your server when the user clicks on a particular file. That would require passing the file data through your server each time though.
And yes, your understanding of the Embedder is correct. It would take a single shared link for the parent folder, and would then list everything in that linked parent folder.
About Dropbox API Support & Feedback
Find help with the Dropbox API from other developers.
5,915 PostsLatest Activity: 6 years agoIf 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 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!