One month down in 2025: How are your resolutions coming along? Check out how to get back on track here.
Forum Discussion
babydream
2 years agoHelpful | Level 6
not able to either create or list a share link after a copy of a file
Hello,
Overall objective:
Once I copy a file from a user's folder to our Production folder, I try to create a shared link for it and it fails; or I try to list the shared link and it fails. By fail, I referring to not returning the expected URL. This has me going bananas. Either creating a shared link or listing it returns none 😞
def move_file_to_Baby_Dream(item_found):
global babydream_path
global babydream_web_path
global source_path
global destination_path
source_path = source_path + item_found
if "WEB" in item_found.upper():
destination_path = babydream_web_path + item_found
else:
destination_path = babydream_path + item_found
result = dbx.files_copy_v2(source_path, destination_path)
print(result)
shared_link_metadata = dbx.sharing_list_shared_links(
destination_path)
print(shared_link_metadata)
# can raise exceptions.ApiError
result = dbx.files_delete(source_path)
print(result)
iterm in question:
processing item Beach Vibes (GO) 6x8 WEB.jpg
Result from the copy:
RelocationResult(metadata=FileMetadata(client_modified=datetime.datetime(2023, 3, 12, 14, 58, 39),
RelocationResult(metadata=FileMetadata(client_modified=datetime.datetime(2023, 3, 12, 14, 58, 39),
content_hash='d16046346d27c2b9ebe0c60dfac996b0cb57f3897b2d9c815ee116208d82f336',
export_info=NOT_SET, file_lock_info=NOT_SET, has_explicit_shared_members=NOT_SET, id='id:uyXC_hRuuQsAAAAAAAK7Hg',
is_downloadable=True, media_info=NOT_SET,
name='Beach Vibes (GO) 6x8 WEB.jpg', parent_shared_folder_id='9728791664',
path_display='/Baby Dream CSV WEB/Beach Vibes (GO) 6x8 WEB.jpg',
path_lower='/baby dream csv web/beach vibes (go) 6x8 web.jpg',
preview_url=NOT_SET, property_groups=NOT_SET, rev='015f9d8de48c2c70000000243e19470',
server_modified=datetime.datetime(2023, 4, 21, 13, 45, 21),
sharing_info=FileSharingInfo(modified_by='dbid:AADeY4jnPnF-ARQRTYUMOxc6-ANf3mvEh68',
parent_shared_folder_id='9728791664', read_only=False), size=1251420, symlink_info=NOT_SET))
2nd Print command:
ListSharedLinksResult(cursor=NOT_SET, has_more=False, links=[])
ListSharedLinksResult(cursor=NOT_SET, has_more=False, links=[])
babydream As Здравко said, the code you shared here doesn't show an attempt to create a shared link. Files don't have shared links by default, so sharing_list_shared_links won't list a shared link for a file before one is created. Also, when copying a file, such as using files_copy_v2, a shared link on the original file does not get copied to the new copy of the file.
You can create a shared link using sharing_create_shared_link_with_settings. If that call isn't working as expected, please share the relevant code and error/output.
- Greg-DB
Dropbox Staff
babydream As Здравко said, the code you shared here doesn't show an attempt to create a shared link. Files don't have shared links by default, so sharing_list_shared_links won't list a shared link for a file before one is created. Also, when copying a file, such as using files_copy_v2, a shared link on the original file does not get copied to the new copy of the file.
You can create a shared link using sharing_create_shared_link_with_settings. If that call isn't working as expected, please share the relevant code and error/output.
- babydreamHelpful | Level 6
sharing_create_shared_link_with_settings. Worked quite well. Thank you.
About Dropbox API Support & Feedback
Find help with the Dropbox API from other developers.5,950 PostsLatest Activity: 13 minutes ago
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!