Forum Discussion

psehrawat's avatar
psehrawat
New member | Level 2
9 years ago

How to download files from a publicly shared folder?

We developed an app using an endpoint from v1 /1/metadat/link (to list all from a shared link). I couldn't find any endpoint from v2 having same functionality.

 

My app has a simple a functionality, given a shared link it should download all the files from this shared link. Any help would be appreciated.

16 Replies

Replies have been turned off for this discussion
  • Greg-DB's avatar
    Greg-DB
    Icon for Dropbox Community Moderator rankDropbox Community Moderator
    8 years ago

    RichardTSchaefe The list_folder endpoint unfortunately doesn't support "app authentication" (i.e., so no user access token is required), only "user authentication" (where a user access token is required), so I'm afraid I don't have a good solution for this use case. I'm sending this along as a feature request.

  • RTS S.'s avatar
    RTS S.
    Helpful | Level 6
    8 years ago

    I can traverse the folder Shared Folder using a USER token (as opposed to a App/User token) using the files/list endpoint.

    The path is relative to this shared folder.

     

    Do I use a path of the form {id:UniqueID} ? with the files/download request ?

    Or do I somehow have to use the {sharing_info: ???? } property ? 

     

    If it's the former ... can I use a path of the form {id:UniqueID} in the files/list_folder request ? 

    If I could vote ... I would prefer using {id:UniqueID} doe /list folder ... then to access a folder (your own, or a shared, you only need the UniqueID)... the filesystem like path is then determined by the context of the request.

     

  • Greg-DB's avatar
    Greg-DB
    Icon for Dropbox Community Moderator rankDropbox Community Moderator
    8 years ago

    RTS S. Both /2/files/list_folder and /2/files/download support both file IDs and paths. (You can check the supported formats in the documentation for the 'path' value.)

     

    So, for instance when calling /2/files/list_folder, you can supply the 'path' parameter containing either the 'id' of the folder you want to list, or the full path to the folder.

     

    Likewise, when calling /2/files/download you can supply the 'path' parameter containing either the 'id' of the file you want to download, or the full path to the file.

  • RTS S.'s avatar
    RTS S.
    Helpful | Level 6
    8 years ago

     

    I use the same code to Navigate (files/list_folder) and download (files/download) for both my APP/User token and for a shared folder using a User token.
    I am able to download a file using an id:xxxx for the path using my APP/User token. But having problems with the shared folder:
    
    The following is for a Test File in a Test Account.
    
    URL:
    POST: https://api.dropboxapi.com/2/files/list_folder
    
    post args:
    { "path": "", "shared_link": { "url": "https://www.dropbox.com/sh/tva3ktdtul2qkth/AACU1dkvaBr31u6sIiDstKACa"}, "include_media_info": false, "include_deleted": false}
    
    Result:
    {
      "entries": [
         {".tag": "file", "name": "2-11011_in__flight.jpg.sdvef", "parent_shared_folder_id": "3372935536", "id": "id:sQqvvpADHyAAAAAAAAAAIA", "client_modified": "2018-06-21T13:49:31Z", "server_modified": "2018-06-21T13:49:32Z", "rev": "12c90ae970", "size": 99110, "sharing_info": {"read_only": true, "parent_shared_folder_id": "3372935536", "modified_by": "dbid:AACm4Dw3RG5ecK3uwT2z3MVi2GWwuS6rYBg"}, "content_hash": "442d907dc20fffe801d271a6512e5c58906adb157329e5e9356b91e323a9d2bb"}
        ],
        "cursor": "AAH96nNWXINQZ4eyuP2VShr5_NM-LfHyN_XSlyR98jhdwct-3t3fIncgCM7X9Eh_-LRQk4jP-IMK52-wQSQKFXCGyseUo3xm8Izh8_9GI_9_EVbB1RYrEiGV9BLNX3znJKUhxnsB8_Q_euGZBBe_X34_0f85NXG595ciaEmzWj7HtXhfLEFQPhlCqu05XoRSQUs8NNkHU3up60VaD6-Zp6Fsn2iem9h9gLuQIWpc8C9O-meRNmAyafZW9FvTT2zAi8r6xkUg-BUJkLUYYVTNmTM_",
        "has_more": false
    }
    
    
    URL:
    GET https://content.dropboxapi.com/2/files/download
    Headers:
        Dropbox-API-Arg {"path":"id:sQqvvpADHyAAAAAAAAAAIA"}
        Range  bytes=0-99109
    Result:
    ERROR:
        Content: {"error_summary": "path/not_found/.", "error": {".tag": "path", "path": {".tag": "not_found"}}}
        Headers: {
        	     Content-Security-Policy: sandbox, sandbox allow-forms allow-scripts
      	     Connection: keep-alive
    	     Server: nginx
    	     X-WebKit-CSP: sandbox
    	     Transfer-Encoding: chunked
    	     Date: Tue, 26 Jun 2018 23:35:18 GMT
    	     X-Content-Security-Policy: sandbox
    	     Vary: Dropbox-API-Arg, Authorization
    	     X-Robots-Tag: noindex, nofollow, noimageindex
    	     X-Content-Type-Options: nosniff
    	     X-Dropbox-Request-Id: 8e068903125489c79e7132583f05b8d7
    	     }
    

    Do I need to do something different for downloaing a file from a shared URL ? I provided the public link .... but it's a test account with a test folder with a single file. I provided it so you might try accessing the file ... 

  • Greg-DB's avatar
    Greg-DB
    Icon for Dropbox Community Moderator rankDropbox Community Moderator
    8 years ago

    RTS S. I see, thanks for clarifying and providing the sample. In this case, based on this error, it sounds like you have a shared link from a different user than the one that the access token is for. That being the case, you can't directly access the file via ID, since it isn't in the authorized user's account.

     

    Instead, after listing the contents, to download a file from the folder that the shared link points to, you should use /2/sharing/get_shared_link_file (instead of /2/files/download). That allows you to download files based on the shared link itself.

  • RTS S.'s avatar
    RTS S.
    Helpful | Level 6
    8 years ago

    Thank you ... I have everything I need.

     

    As I indicated it would still be a nice feature to be able to access to a publicly shared folder/file without the need to authenticate any user.

    If I have the shared URL as an end user I can use a browser to navigate the folder and download a publicly shared folder ... I do not need to authenticate with any dropbox account.  

     

    I should be able to do the same with maybe an APP TOKEN (not a login to the dropbox app) to provide some traceability. Then providing the URL I should be able to navigate and download the publicly shared files and folders. 

About Dropbox API Support & Feedback

Node avatar for 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!