We are aware of the issue with the badge emails resending to everyone, we apologise for the inconvenience - learn more here.

Forum Discussion

Tribecube T.'s avatar
Tribecube T.
New member | Level 1
10 years ago

How to get the file path from a preview link?

How can I get the proper Dropbox file path from a preview link obtained from the Dropbox Chooser? It is obviously unreliable to search for any file that matches the file name...

  • Greg-DB's avatar
    Greg-DB
    Icon for Dropbox Staff rankDropbox Staff

    There currently isn't an officially supported way to get the original path from a shared link returned by the Chooser, but I'll be sure to pass this along as a request.

  • Greg-DB's avatar
    Greg-DB
    Icon for Dropbox Staff rankDropbox Staff

    [Edit to clarify]

    Actually, apologies, this doesn't get returned directly by the Chooser, but this is possible to get now depending on the link type setting you're using with the Chooser. That is, if you use the "preview" link type, you can then pass the link to /metadata/link to get the metadata, including path:

    https://www.dropbox.com/developers-v1/core/docs#metadata-link

    Note, that this call needs to be made using the correct user's auth in order to return the path information.

  • David W.136's avatar
    David W.136
    Helpful | Level 6

    Is there any way to get the path name of a file selected via the Chooser? That would be enormously helpful.

  • Greg-DB's avatar
    Greg-DB
    Icon for Dropbox Staff rankDropbox Staff

    By "correct user's auth", I meant that in order to get the extra information such as "path", you need to make that API call using an access token for the user account that owns the link.

    E.g., see the /metadata/link documentation for in_dropbox and path:

    "in_dropbox: Returns true if the file or folder is in the authenticated user's Dropbox. If no access token is passed, then this will always return false.

    path: Returns the path to the file or folder relative to the shared link's root. If the in_dropbox value is true and the shared link points to a file or folder within the authenticated user's Dropbox, it returns the same path that would be returned by the /metadata endpoint. If the request is made without an authenticated user or the shared link is not in the authenticated user's Dropbox, this will always return null."

  • David W.136's avatar
    David W.136
    Helpful | Level 6

    I hesitate to say this, because I am a terrible, terrible hobbyist programmer, but, I wrote up a tutorial on this. 

About Dropbox API Support & Feedback

Node avatar for Dropbox API Support & Feedback

Find help with the Dropbox API from other developers.

5,877 PostsLatest Activity: 2 hours ago
325 Following

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 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!