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: 

How to download files from a publicly shared folder?

How to download files from a publicly shared folder?

psehrawat
New member | Level 2

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 16

Greg-DB
Dropbox Staff
I don't currently have a solution to offer for this on API v2 unfortunately. I just replied to your ticket though and granted your app an extension. Please check the reply there for details.

Greg-DB
Dropbox Staff
For reference, Dropbox API v2 now supports listing the contents of a shared link for a folder. This can be accomplished using the same interface as listing a folder in a connected user's account, via the list_folder functionality. To list the contents of a shared link for a folder, you instead provide the shared link URL in the `shared_link` parameter to list_folder:

https://www.dropbox.com/developers/documentation/http/documentation#files-list_folder

If you're using an official SDK, there will also be a corresponding method for this endpoint:


In the .NET SDK that's available as `ListFolderAsync`:

https://dropbox.github.io/dropbox-sdk-dotnet/html/M_Dropbox_Api_Files_Routes_FilesUserRoutes_ListFol...


In the Java SDK that's available via `listFolderBuilder` to get a `ListFolderBuilder` on which you can call `ListFolderBuilder.withSharedLink`:

https://dropbox.github.io/dropbox-sdk-java/api-docs/v3.0.x/com/dropbox/core/v2/files/DbxUserFilesReq...

https://dropbox.github.io/dropbox-sdk-java/api-docs/v3.0.x/com/dropbox/core/v2/files/ListFolderBuild...

https://dropbox.github.io/dropbox-sdk-java/api-docs/v3.0.x/com/dropbox/core/v2/files/ListFolderBuild...


In the JavaScript SDK that's available as `filesListFolder`:

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


In the Python SDK that's available as `files_list_folder`:

https://dropbox-sdk-python.readthedocs.io/en/latest/moduledoc.html#dropbox.dropbox.Dropbox.files_lis...


In the Swift SDK that's available as `listFolder`:

https://dropbox.github.io/SwiftyDropbox/api-docs/latest/Classes/FilesRoutes.html#/s:13SwiftyDropbox1...


In the Objective-C SDK that's available as `listFolder`:

https://dropbox.github.io/dropbox-sdk-obj-c/api-docs/latest/Classes/DBFILESUserAuthRoutes.html#/c:ob...:

elsigh
Helpful | Level 5

I'm having the same issue. I have a shared_link to a folder and I'd like to enumerate each file in that folder and be able to download each one independently.

 

I'm using the Javascript version of the SDK.

 

So I'm calling 

filesListFolder({url: "", shared_link: {url: myURL}}

and that returns a list of file metadata but I cannot figure out a way to go from that response and the data in each file's metadata to something I can use with the filesDownload (id seems surprisingly not-useful for non-mounted content) or any of the sharing download functions (which all require an URL for each file which is not something in the response).

 

How can I do this?

Greg-DB
Dropbox Staff

To download a file from a shared link for a folder using the JavaScript SDK, use the sharingGetSharedLinkFile method. You should supply the original shared link, i.e., the same URL you passed to filesListFolder, as well as the relative path for the particular file in the folder you want to download.

elsigh
Helpful | Level 5

Ok, I tried this and I can't make it work.

 

for instance I have the shared link (to a folder full or text files):

https://www.dropbox.com/sh/pytim78xyjqj3di/AACXk4N35DeQpR14dPxLRFOla?dl=0

 

Inside that folder, as enumerated by filesListFolder I have items like:

{
  ".tag": "file",
  "name": "willin.pro",
  "parent_shared_folder_id": "1699528",
  "id": "id:LmyYmvEGCjcAAAAAAAC4TA",
  "client_modified": "2018-03-18T20:35:30Z",
  "server_modified": "2018-03-18T20:37:13Z",
  "rev": "18f2e2f80019eec8",
  "size": 1631,
  "sharing_info": {
    "read_only": true,
    "parent_shared_folder_id": "1699528",
    "modified_by": "dbid:AAAkG7maZxQE1y3-wnhlj6tstjqqo8rqYow"
  },
  "content_hash": "896e0660f614202d880a7010f4f6c55cdf1141cffa0d3c1dcdfcbec3ebbdcc00"
}

 

So I tried

 

 

dbxClient.sharingGetSharedLinkFile({
  url: "https://www.dropbox.com/sh/pytim78xyjqj3di/AACXk4N35DeQpR14dPxLRFOla?dl=0", 
  path: "/id:LmyYmvEGCjcAAAAAAAC4TA"
})

and I tried:

dbxClient.sharingGetSharedLinkFile({
  url: "https://www.dropbox.com/sh/pytim78xyjqj3di/AACXk4N35DeQpR14dPxLRFOla?dl=0", 
  path: "/willin.pro"
})

The latter 2 get 409s.

 

Greg-DB
Dropbox Staff

@elsigh The first one is incorrect because this endpoint doesn't support file IDs in that `path` parameter. (If it did though, you would supply just the "id:..." string, without a leading slash.)

 

The second one is correct, and it works for me. Can you share the full output you're getting?

 

(Make sure to use both `then` and `catch`, so you can get the API response or error, respectively.)

elsigh
Helpful | Level 5
dbxClient.sharingGetSharedLinkFile({url: "https://www.dropbox.com/sh/pytim78xyjqj3di/AACXk4N35DeQpR14dPxLRFOla?dl=0", path: "/winllin.pro"}).then(resp => { console.log(resp); }).catch(err => { console.error(err); })

 

 

{"error_summary": "shared_link_not_found/.", "error": {".tag": "shared_link_not_found"}}

Greg-DB
Dropbox Staff

It looks like you just have a typo in your `path` value. You have "/winllin.pro" instead of "/willin.pro". (Note the extra 'n'.)

elsigh
Helpful | Level 5

Ah, egads, thank you!

Need more support?
Who's talking

Top contributors to this post

  • User avatar
    RTS S. Helpful | Level 6
  • User avatar
    Greg-DB Dropbox Staff
What do Dropbox user levels mean?