We Want to Hear From You! What Do You Want to See on the Community? Tell us here!

Forum Discussion

Legalas61's avatar
Legalas61
Explorer | Level 3
6 years ago

How to insert a picture from the application on the site?

Hi Dropbox!
Now I am learning Django, I am creating the first application. Deployed this application to Heroku. As a file storage for pictures, I decided to use Dropbox.
Now I am adding a picture to record Django in the admin panel and it will appear in the Dropbox application, but I don’t understand how to get a link to it (so that it appears on the site).

I do this:

dbx = dropbox.Dropbox(settings.DROPBOX_OAUTH2_TOKEN)
    shared_link_metadata = dbx.sharing_create_shared_link_with_settings("/" + str(post.images))

    print(shared_link_metadata)

to view.py

But I get:

ApiError('6d0d5986e4daa4aa3cb644556bd30989', CreateSharedLinkWithSettingsError('shared_link_already_exists', SharedLinkAlreadyExistsMetadata('metadata', FileLinkMetadata(url='https://www.dropbox.com/s/55dbx3w7hq6ejp2/regular_picture-e8d4091b6a6d555b697bac3f9af0d728.jpg?dl=0', name='regular_picture-e8d4091b6a6d555b697bac3f9af0d728.jpg', link_permissions=LinkPermissions(can_revoke=True, resolved_visibility=ResolvedVisibility('public', None), requested_visibility=RequestedVisibility('public', None), revoke_failure_reason=None, effective_audience=None, link_access_level=None), client_modified=datetime.datetime(2019, 11, 17, 11, 53, 39), server_modified=datetime.datetime(2019, 11, 17, 11, 53, 39), rev='01597897b57ca2a000000018cea2e10', size=79820, id='id:jC4nvt6nxLAAAAAAAAAAUg', expires=None, path_lower='/media/regular_picture-e8d4091b6a6d555b697bac3f9af0d728.jpg', team_member_info=None, content_owner_team_info=None))))


Help please ...

4 Replies

  • Greg-DB's avatar
    Greg-DB
    Icon for Dropbox Community Moderator rankDropbox Community Moderator
    6 years ago

    That 'shared_link_already_exists' error indicates that the call failed because a shared link for the requested item already exists. 

    You can either get the shared link information from the SharedLinkAlreadyExistsMetadata, if given in the CreateSharedLinkWithSettingsError error, as shown in your output, or call sharing_list_shared_links to retrieve it. (Likewise, you can call sharing_list_shared_links first, to check for a shared link, if you prefer.)

  • Legalas61's avatar
    Legalas61
    Explorer | Level 3
    6 years ago

    Thanks for the advice! The method helped to get the link,

    <img class="main_img" src="'https://www.dropbox.com/s/55dbx3w7hq6ejp2/regular_picture-e8d4091b6a6d555b697bac3f9af0d728.jpg?dl=0" alt="***">

    but the browser does not display the image. Can I get a direct link, not a download link?

  • Legalas61's avatar
    Legalas61
    Explorer | Level 3
    6 years ago

    Not. Too many restrictions and difficult to implement. I solved the problem by switching to another service. Thank you for your time.

About Dropbox API Support & Feedback

Node avatar for Dropbox API Support & Feedback
Find help with the Dropbox API from other developers.6,036 PostsLatest Activity: 9 months ago
411 Following

The Dropbox Community team is active from Monday to Friday. We try to respond to you as soon as we can, usually within 2 hours.

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!