cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Announcements
Want to learn some quick and useful tips to make your day easier? Check out how Calvin uses Replay to get feedback from other teams at Dropbox 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: 

Distinguish shared link and preview links

Distinguish shared link and preview links

Mhd
Explorer | Level 4

Am I correct to assume the following:

a shared link will alawys have /s/ in the URL

The original preview link is of the from : www.dropbox.com/home/path/to/file?preview=filename.pdf

What I am trying to do
I have a list of URLs in my DB, and I need to use the API to generate a preview and embed it in a webpage

for the original preview links, I am parsing the lnk to extract the path and then use the get_preview endpoint
for the shared link, I am thinking about calling get_shared_link_metadata and from there get the id and call get_preview 

Is there an easier way to do this?

2 Replies 2

Greg-DB
Dropbox Staff
Dropbox shared links for files do currently have /s/, but there are other kinds of links. E.g., shared links for folders use /sh/.

In any case though, these link formats are not guaranteed and are subject to change in the future, so you shouldn't rely on them.

Likewise, you shouldn't rely on the "www.dropbox.com/home/path/to/file?preview" format.

You can list the files/folders in your account directly though, using list_folder and list_folder continue. That will return file metadata including path and id.

Using the paths you get from those, you can call the other methods as necessary, e.g., get_preview to get preview data, create_shared_link_with_settings to create shared links, list_shared_links to retrieve existing shared links, etc.



Mhd
Explorer | Level 4

Hello Greg,

Thanks for the detailed answer. 

I tried to go with with list_folder and list_folder/continue. But there are thousnads of files and it was not practical.
Also, sometimes a user have a sharing link but the file is not shared with their dropbox account, they only have the public sharing link, so I can't use this option. 


It would be great if there was a way to get the meta data of a file through a link , despite what kind of link it is. 

For now, I will relay on get_shared_link_metadata and if it failesI will assume it is a preview link and parse it accorrdingly.
and I will limit URLs I have to sharing links only from now on.

Thanks again for your answer, please let me know if there is an easier approach 

Need more support?
Who's talking

Top contributors to this post

  • User avatar
    Mhd Explorer | Level 4
  • User avatar
    Greg-DB Dropbox Staff
What do Dropbox user levels mean?