cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Announcements
What’s new: end-to-end encryption, Replay and Dash updates. Find out more about these updates, new features and more here.

Dropbox API Support & Feedback

Find help with the Dropbox API from other developers.

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Best way to get a file's URL

Best way to get a file's URL

quocvu
Explorer | Level 3

There are photos in shared folder that I have access to.  I would like to get the URL of the photos (the JPEG/PNG) in that folder using the V2 NodeJS API.

 

I am able to enumerate the files in the folder using filesListFolder().  How do I use the "id" or "name" to get the URL.  I would like to have a permanent URL instead of a temporary since I will be storing that value in my DB.

7 Replies 7

Greg-DB
Dropbox Staff
You can use sharingCreateSharedLinkWithSettings to make a shared link for any file or folder:

https://dropbox.github.io/dropbox-sdk-js/Dropbox.html#sharingCreateSharedLinkWithSettings__anchor

Or, if the shared link already exists, you can use sharingListSharedLinks to retrieve it:

https://dropbox.github.io/dropbox-sdk-js/Dropbox.html#sharingListSharedLinks__anchor

(You may want to use SharingListSharedLinksArg.direct_only to restrict that call to the specific item only.)

pigelectric
New member | Level 2
As you mention, a shared link must exist for the sharing-list-shared-links to retrieve it.

The issue I am facing is trying to get a shared link to generate for all files in a folder. I tried using the sharing-create-shared-link with settings API but it only seems to generate the shared link on a folder or individual file basis.

How do I get every file in a folder to have a shared link, without having to go through each file one by one?
THANK YOU

Greg-DB
Dropbox Staff
There isn't a way to create a shared link for every file in a folder without making a call for each one unfortunately. You'll need to list the files and call sharingCreateSharedLinkWithSettings on each one.

pigelectric
New member | Level 2

Oh darn, I was thinking that might be the case. Is there a way to automate that ?

Greg-DB
Dropbox Staff

You can iterate through the file list (e.g., as returned by filesListFolder and filesListFolderContinue) and call sharingCreateSharedLinkWithSettings for each desired item.

quocvu
Explorer | Level 3

Thanks Greg.  Can I do that even though I am not the owner of the shared folder?

 

Can you explain what is the use of the id (of files or folders)  returned by filesListFolder().  I believe when the argument is specified as path, we are talking about this: <folder name>/<folder name>/<filename>

 

Then what is the path if we are within a shared folder?  is that shared folder considered to be the root?

Greg-DB
Dropbox Staff
Yes, you can use these methods for files/folders inside a shared folder even if you are not the owner of the shared folder. As long as you are a member of the shared folder, the contents will exist in your account for you to use, the same as you can see on the website.

The 'id' for a file/folder is just another way to identify a particular item. Some API endpoints support supplying a file ID instead of a file path. The advantage to a file ID is that it doesn't change when a file is moved, for example.

Whether or not a file is in a shared folder, the path is relative to the root that your app can see. That is the root of the Dropbox itself for apps with the "full Dropbox" permission, and the app folder for apps with the "app folder" permission. The paths for items are included in the Metadata objects for those items, e.g., as returned by filesListFolder.
Need more support?
Who's talking

Top contributors to this post

  • User avatar
    Greg-DB Dropbox Staff
  • User avatar
    quocvu Explorer | Level 3
  • User avatar
    pigelectric New member | Level 2
What do Dropbox user levels mean?