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.

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: not able to either create or list a share link after a copy of a file

not able to either create or list a share link after a copy of a file

babydream
Helpful | Level 6
Go to solution

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),
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=[])
1 Accepted Solution

Accepted Solutions

Greg-DB
Dropbox Staff
Go to solution

@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.

View solution in original post

3 Replies 3

Здравко
Legendary | Level 20
Go to solution

Hi @babydream,

Where are you creating your links? 🤔 You can list existing links only; if there is no any link, as seems it's, the result you got is something normal.

Greg-DB
Dropbox Staff
Go to solution

@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.

babydream
Helpful | Level 6
Go to solution

sharing_create_shared_link_with_settings. Worked quite well.  Thank you.

Need more support?