cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Announcements
Want to know what we learned at IBC? Check out our learnings on media, remote working and more right here.

Discuss Dropbox Developer & API

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

create custom link

create custom link

alicera
Explorer | Level 3

Could I make a specific link for my data in dropbox.

https://www.dropbox.com/s/uddsf6r7ba/folder1/hello.json?dl=0

https://www.dropbox.com/s/uddsf6r7ba/folder2/aa.json?dl=0

data/

     ├── folder1   

                 ├── hello.json

                 ├── haha.json

     ├── folder2   

                 ├── aa.json

5 Replies 5

Greg-DB
Dropbox Staff

Yes, you can use /2/files/list_folder[/continue] (files_list_folder/files_list_folder_continue and filesListFolder/filesListFolderContinue in the Python SDK and JavaScript SDKs, respectively) to list the contents under any particular path. You can use /2/sharing/create_shared_link_with_settings (sharing_create_shared_link_with_settings and sharingCreateSharedLinkWithSettings in the Python SDK and JavaScript SDKs, respectively) to create a shared link for any particular file or folder.

 

I recommend reading the File Access Guide and Sharing Guide.

alicera
Explorer | Level 3
```
dbx.sharing_create_shared_link_with_settings('/data/')
dbx.sharing_create_shared_link_with_settings('/data/'1.jpg)
At the dropbox have it.
```
It doesnt work.
 
```
Traceback (most recent call last):
File "share.py", line 57, in <module>
shared_link_metadata = dbx.sharing_create_shared_link_with_settings("/Model/s.pt", settings=None)
File "/opt/conda/lib/python3.8/site-packages/dropbox/base.py", line 4131, in sharing_create_shared_link_with_settings
r = self.request(
File "/opt/conda/lib/python3.8/site-packages/dropbox/dropbox_client.py", line 348, in request
raise ApiError(res.request_id,
dropbox.exceptions.ApiError: ApiError(
```

Greg-DB
Dropbox Staff

Can you share the full error message? You seem to have truncated the output here.

alicera
Explorer | Level 3

Here is my code

```

dbx = dropbox.Dropbox()
shared_link_metadata = dbx.sharing_create_shared_link_with_settings("/Model/s.pt")
```

 

Message

Here is I use the No expiration token

Is it safe for me to show metadata here ?

 

/Pictures/Dropbox/dropbox-sdk-python/example# python share.py

Traceback (most recent call last):
File "share.py", line 55, in <module>
shared_link_metadata = dbx.sharing_create_shared_link_with_settings("/Model/s.pt")
File "/opt/conda/lib/python3.8/site-packages/dropbox/base.py", line 4131, in sharing_create_shared_link_with_settings
r = self.request(
File "/opt/conda/lib/python3.8/site-packages/dropbox/dropbox_client.py", line 348, in request
raise ApiError(res.request_id,
dropbox.exceptions.ApiError: ApiError('731fb539203145e39e640cb66d80d3e3', CreateSharedLinkWithSettingsError('shared_link_already_exists', SharedLinkAlreadyExistsMetadata('metadata', FileLinkMetadata(client_modified=datetime.datetime(2021, 12, 16, 5, 1, 30), content_owner_team_info=NOT_SET, expires=NOT_SET, id='id:QTPba1EnHBoAAAAAAAAADA', link_permissions=LinkPermissions(allow_comments=True, allow_download=True, audience_options=[LinkAudienceOption(allowed=True, audience=LinkAudience('public', None), disallowed_reason=NOT_SET), LinkAudienceOption(allowed=False, audience=LinkAudience('team', None), disallowed_reason=LinkAudienceDisallowedReason('user_not_on_team', None)), LinkAudienceOption(allowed=True, audience=LinkAudience('no_one', None), disallowed_reason=NOT_SET), LinkAudienceOption(allowed=False, audience=LinkAudience('password', None), disallowed_reason=LinkAudienceDisallowedReason('user_account_type', None))], can_allow_download=True, can_disallow_download=False, can_remove_expiry=True, can_remove_password=False, can_revoke=True, can_set_expiry=False, can_set_password=False, can_use_extended_sharing_controls=NOT_SET, effective_audience=NOT_SET, link_access_level=NOT_SET, requested_visibility=RequestedVisibility('public', None), require_password=NOT_SET, resolved_visibility=ResolvedVisibility('public', None), revoke_failure_reason=NOT_SET, team_restricts_comments=False, visibility_policies=[VisibilityPolicy(allowed=True, disallowed_reason=NOT_SET, policy=RequestedVisibility('public', None), resolved_policy=AlphaResolvedVisibility('public', None)), VisibilityPolicy(allowed=False, disallowed_reason=VisibilityPolicyDisallowedReason('user_not_on_team', None), policy=RequestedVisibility('team_only', None), resolved_policy=AlphaResolvedVisibility('team_only', None)), VisibilityPolicy(allowed=False, disallowed_reason=VisibilityPolicyDisallowedReason('user_account_type', None), policy=RequestedVisibility('password', None), resolved_policy=AlphaResolvedVisibility('password', None))]), name='s.pt', path_lower='/model/s.pt', rev='015d33c53215f7d000000024ae230a0', server_modified=datetime.datetime(2021, 12, 16, 5, 2, 9), size=6, team_member_info=NOT_SET, url='<REDACTED>))))


Greg-DB
Dropbox Staff

This particular error includes the shared link metadata, so you would want to redact the shared link if you don't wish to post that. I've redacted it for you just in case.

 

Anyway, this error says 'shared_link_already_exists' meaning that a new shared link was not created because one already exists. You can find error types in the documentation, such as here for this CreateSharedLinkWithSettingsError. In some cases like this the existing metadata will be returned in the error which you can get from SharedLinkAlreadyExistsMetadata. You can also call sharing_list_shared_links to list existing shared links. Refer to the documentation for that for the available options when doing so.

Need more support?
Who's talking

Top contributors to this post

  • User avatar
    Greg-DB Dropbox Staff
  • User avatar
    alicera Explorer | Level 3
What do Dropbox user levels mean?