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: 

Re: General URL for many files from 1 shared folder

General URL for many files from 1 shared folder

denne
Explorer | Level 3
Go to solution

Hello community,

In my dropbox I have a folder with 200 country flags which I would like to download automatically using the respective URLs.
My problem is that the URL of every single file contains a key which is unique.
Example:
- for the USA flag the URL is https://dl.dropboxusercontent.com/s/rzateuez21i5c95/us.png?dl=0
- for the Gereat Britain flag the URL is https://dl.dropboxusercontent.com/s/2ct7i7ov5zf6r0z/gb.png?dl=0
Every URL consists of four parts: https://dl.dropboxusercontent.com s/XXXXXXXXXXXXX/ FILENAME.FILEFORMAT ?dl=0
So every shared file gets its own key s/XXXXXXXXXXXXX/ which is unique.

Is is it somehow possible to create a URL without this unique key part s/XXXXXXXXXXXXX/ ?
Something like this: https://dl.dropboxusercontent.com/us.png?dl=0

Thank you

1 Accepted Solution

Accepted Solutions

Greg-DB
Dropbox Staff
Go to solution
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

You can also get the shared link metadata and file data using:

https://www.dropbox.com/developers/documentation/http/documentation#sharing-get_shared_link_metadata

https://www.dropbox.com/developers/documentation/http/documentation#sharing-get_shared_link_file

If you're using an official SDK, there will also be corresponding methods for these endpoints.

So, you could use a shared link for a folder and then programmatically list and access the contents.

View solution in original post

12 Replies 12

Sanchez
Dropbox Staff
Go to solution
Hey @denne, welcome to our forum! 

As far as getting these links in a different format… I’m afraid not, because that’s just the way our links work. However, to see if there is something else we can come up with, I require a bit of clarification on what you’d like to be able to do here :thinking:
 
Can you give me a bit more detail? We may be able to this a different way. 

Thanks, and have a great weekend :sunglasses:
 

Sanchez
Community Moderator @ Dropbox
dropbox.com/support


Heart Did this post help you? If so, give it a Like below to let us know.
:arrows_counterclockwise: Need help with something else? Ask me a question!
:pushpin: Find Tips & Tricks Discover more ways to use Dropbox here!
:arrows_counterclockwise: What do you think about the Community? Fill out our survey here!

denne
Explorer | Level 3
Go to solution

Hey @Sanchez,

 

thank you for your feedback.

 

What I'm trying to do is the following:

I'd like my code to use the dropbox URL and get files depending from the value of a variable.

My code is able to get the static part of the dropbbox URL and the variable name of the file (for example, for the Great Britain it is gb.png), but it fails to get the unique key (/s/xxxxxxxxxx).

 

Example: in case of Great Britain the value of the variable is "gb" 

- the whole URL is https://dl.dropboxusercontent.com/s/2ct7i7ov5zf6r0z/gb.png?dl=0

- the static part of the URL is https://dl.dropboxusercontent.com/s/                        ?dl=0

- the variable part of the URL is 2ct7i7ov5zf6r0z   and gb.png

My code is able to get the file name ( gb.png ) but not the unique keys ( 2ct7i7ov5zf6r0z )

Is it somehow possible to create dropbox URL without unique keys (like 2ct7i7ov5zf6r0z) ?

 

Thank you,

Denne

 

Mark
Super User II
Go to solution
Is this for an app you are developing Denne?

If so I'll move this to the API area where the API team may be able to help

 


:penguin::penguin: - :penguin: - :penguin: - :penguin:


Heart Did this post help you? If so please mark it for some Kudos below. 


:white_check_mark: Did this post fix your issue/answer your question? If so please press the 'Accept as Solution' button to help others find it.


:arrows_counterclockwise: Did this post not resolve your issue? If so please give us some more information so we can try and help - please remember we cannot see over your shoulder so be as descriptive as possible! 


 

denne
Explorer | Level 3
Go to solution

Hi Mark,

yes, it is for an app I'm playing with.

My idea was: to show country flags which I hold in my dropbox, but every single flag-file has not only a file name (like gb.png) but also a dropbox key (/s/xxxxxxxxxxx) for that file which makes the whole URL unique and thus impossible to generalize the call of the URL.

Thank you,
Denne

Greg-DB
Dropbox Staff
Go to solution
Hi Denne, Sanchez is correct, there isn't a way to get a general shared link like this, but I'll pass this along as a feature request.

Greg-DB
Dropbox Staff
Go to solution
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

You can also get the shared link metadata and file data using:

https://www.dropbox.com/developers/documentation/http/documentation#sharing-get_shared_link_metadata

https://www.dropbox.com/developers/documentation/http/documentation#sharing-get_shared_link_file

If you're using an official SDK, there will also be corresponding methods for these endpoints.

So, you could use a shared link for a folder and then programmatically list and access the contents.

denne
Explorer | Level 3
Go to solution

Thank you Greg! I'll give it a try

duckladydinh
Explorer | Level 4
Go to solution

I confirmed that this method is not going to work. The json response contains entries with id, tag and so one, but you cannot really download the subfolders or anything with them.

Greg-DB
Dropbox Staff
Go to solution

@duckladydinh I'm not sure I understand your comment. If something isn't working as documented, please share the details so we can look into it for you.

For example, you can use the /2/files/list_folder endpoint to list the contents of a folder from a shared link for the folder:

curl -X POST https://api.dropboxapi.com/2/files/list_folder \
    --header "Authorization: Bearer <ACCESS_TOKEN>" \
    --header "Content-Type: application/json" \
    --data "{\"path\": \"\",\"shared_link\": {\"url\": \"<SHARED_LINK_FOR_FOLDER>\"}}"

# {
#   "entries": [
#     {
#       ".tag": "folder",
#       "name": "Test",
#       "path_lower": "/test shared folder/test",
#       "path_display": "/test shared folder/Test",
#       "parent_shared_folder_id": "248930168",
#       "id": "id:uKXaztDfaPQAAAAAAAAABA",
#       "sharing_info": {
#         "read_only": false,
#         "parent_shared_folder_id": "248930168",
#         "traverse_only": false,
#         "no_access": false
#       }
#     },
# <redacted for brevity>
#   ],
#   "cursor": "<redacted for brevity>",
#   "has_more": false
# }

And you can also list sub-folders like that using the "path" parameter:

curl -X POST https://api.dropboxapi.com/2/files/list_folder \
    --header "Authorization: Bearer <ACCESS_TOKEN>" \
    --header "Content-Type: application/json" \
    --data "{\"path\": \"/test\",\"shared_link\": {\"url\": \"<SHARED_LINK_FOR_FOLDER>\"}}"

# {
#   "entries": [
# <redacted for brevity>
#     {
#       ".tag": "file",
#       "name": "test.txt",
#       "path_lower": "/test shared folder/test/test.txt",
#       "path_display": "/test shared folder/Test/test.txt",
#       "parent_shared_folder_id": "248930168",
#       "id": "id:uKXaztDfaPQAAAAAAAAB3w",
#       "client_modified": "2018-05-10T17:07:46Z",
#       "server_modified": "2019-10-18T20:35:37Z",
#       "rev": "5953546d8c26e0ed65f78",
#       "size": 4,
#       "sharing_info": {
#         "read_only": false,
#         "parent_shared_folder_id": "248930168",
#         "modified_by": "<redacted for brevity>"
#       },
#       "is_downloadable": true,
#       "content_hash": "954d5a49fd70d9b8bcdb35d252267829957f7ef7fa6c74f88419bdc5e82209f4"
#     }
#   ],
#   "cursor": "<redacted for brevity>",
#   "has_more": false
# }

And then you can download a listed file using /2/sharing/get_shared_link_file by likewise using the relative path:

curl -X POST https://content.dropboxapi.com/2/sharing/get_shared_link_file \
    --header "Authorization: Bearer <ACCESS_TOKEN>" \
    --header "Dropbox-API-Arg: {\"url\": \"<SHARED_LINK_FOR_FOLDER>\",\"path\": \"/test.txt\"}"

# test file contents
Need more support?