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

Forum Discussion

Pearman's avatar
Pearman
Explorer | Level 3
5 years ago

How to dowload a shared file by its id?

I'm trying to make a simple web app that will list contents on one particular shared folder. There is about 200 small excel files in that folder and the app would like to download those files and do some magic on them.

 

I was able to list all files with: 

dbx.filesListFolder({
  path: "/some path",
  include_media_info: true,
  shared_link: {
    url: "https://www.dropbox.com/sh/id_or_whatever/another_random_string?dl=0"
  }
})

 

Now I would like to download all the files and do something with them.
I tried `filesDownloadZip` but it rejected path in form of "id:asdfasdf" where asdfasddf is a string I got from parent_shared_folder_id  

`filesDownload` throws the same error. Other posts on this forum mentioned `sharingGetSharedLinkFile` but that requires some kind of preview link.

 

Thanks in advance.

  • You can use filesDownloadZip (for an entire folder) or filesDownload (for a specific file) if the file/folder is in the account that you're connected to (i.e., for the access token you're using). In that case, the 'id' should just be the 'id' property returned in the relevant FilesFileMetadata or FilesFolderMetadata object you got from filesListFolder. You should not try to construct that value yourself. (The 'parent_shared_folder_id' is a different kind of ID.) Likewise, if the folder is in the connected account, you can list the contents using filesListFolder/filesListFolderContinue without passing in the shared link, by instead just using the relevant path in the account.

     

    If the content is not in the connected account though, you will need to instead use sharingGetSharedLinkFile instead, like you mentioned. You do need to pass in the 'url' and 'path' in that case, but the 'url' in that case is the same "https://www.dropbox.com/sh/..." you used originally.

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

    You can use filesDownloadZip (for an entire folder) or filesDownload (for a specific file) if the file/folder is in the account that you're connected to (i.e., for the access token you're using). In that case, the 'id' should just be the 'id' property returned in the relevant FilesFileMetadata or FilesFolderMetadata object you got from filesListFolder. You should not try to construct that value yourself. (The 'parent_shared_folder_id' is a different kind of ID.) Likewise, if the folder is in the connected account, you can list the contents using filesListFolder/filesListFolderContinue without passing in the shared link, by instead just using the relevant path in the account.

     

    If the content is not in the connected account though, you will need to instead use sharingGetSharedLinkFile instead, like you mentioned. You do need to pass in the 'url' and 'path' in that case, but the 'url' in that case is the same "https://www.dropbox.com/sh/..." you used originally.

    • Pearman's avatar
      Pearman
      Explorer | Level 3

      Cool, Thanks a lot, Greg.

      Have a wonderful day.

About Dropbox API Support & Feedback

Node avatar for Dropbox API Support & Feedback

Find help with the Dropbox API from other developers.

5,876 PostsLatest Activity: 6 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!