cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Announcements
Check out the Dropbox cheat sheet for getting started in 2021 here!

Discuss Dropbox Developer & API

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

Problem of uploading image to dropbox shared link using url

Problem of uploading image to dropbox shared link using url

Explorer | Level 3

I am trying to upload the image to the dropbox shared link using the URL  but I did not get the path of this shared link. I'm using the below code to get the metadata of the shared folder link but I did not get a path_lower in response.

 

dbx.sharingGetSharedLinkMetadata({url: req.body.reference})
    .then(function(response) {
        console.log(response);
        var pathname =  response.result.path_lower;
        dbx.filesUpload({path: "/"+pathname, contents: data})
            .then(function(response) {
            console.log(response);
            })
            .catch(function(error) {
                console.error(error);
            });
    
    })
    .catch(function(error) {
        console.error(error);
    });

I appreciate your help. Thank You.

11 Replies 11

Re: Problem of uploading image to dropbox shared link using url

Dropboxer

The SharingFileLinkMetadata.path_lower (as returned by sharingGetSharedLinkMetadata) is "only be present only if the linked file is in the authenticated user's dropbox.". So, it sounds like the linked file doesn't exist in the account that you're connected to.

 

In that case, you'd need to supply the path yourself. For instance, perhaps you would want to build one using the returned file name in SharingFileLinkMetadata.name if you want it to have the same name as the linked file.

 

Re: Problem of uploading image to dropbox shared link using url

Explorer | Level 3

Thank You for your response. But the user account that I used is an authenticated user dropbox account.

 

Do you think should I be doing something else to get path_lower from the shared link url?

 

 

Re: Problem of uploading image to dropbox shared link using url

Dropboxer

When you say "the user account that I used is an authenticated user dropbox account.", that doesn't necessarily meet the requirement. 

 

In order to receive the path_lower value, the account for the access token you're using to make the call needs to be the same account as the one that created the shared link.

Re: Problem of uploading image to dropbox shared link using url

Explorer | Level 3

As you told me, the account for the access token which I am using to make the call is the same account as the one that created the shared link.

 

Is there any other way to upload images to shared link programmatically?

Re: Problem of uploading image to dropbox shared link using url

Dropboxer

How are you checking that you're using an access token for the same account as the one that made the shared link? I just tried this functionality and it is working for me. When using the same account, I get the path_lower value. You can use the usersGetCurrentAccount method to check what account a particular access token is for.

 

Using the filesUpload method is a valid way to upload over an existing file in the connected account. You don't need to get the path_lower value from sharingGetSharedLinkMetadata in particular though. You can get the path from wherever you want, e.g., elsewhere on the API, such as from filesListFolder/filesListFolderContinue, etc., or you can even retrieve it from some previous storage in your app, or just hard-code it if it's always the same.

 

In any case, if something isn't working as expected, please share more details so we can look into it. You can also open an API ticket here if you'd prefer to share privately.

Re: Problem of uploading image to dropbox shared link using url

Explorer | Level 3

Thank You for your response.

 

Yes, I used the usersGetCurrentAccount method to check what account a particular access token is for and it is the same account that generated the shared link.

 

I have to upload an image to the shared link. So I need the full path of that shared link folder. Thatswhy I am using sharingGetSharedLinkMetadata API because I only have input as shared link URL. Is there a way to get the folder path from the shared link URL?

 

Every time the shared link will change the path will also change. So it is not possible to hardcode the path. Also, there is no previous storage in that folder to get the path.

Re: Problem of uploading image to dropbox shared link using url

Dropboxer

Yes, using sharingGetSharedLinkMetadata is the right way to get the corresponding path just based on the shared link.

 

If that's not working properly for you, please share a sample so we can look into it. For instance, share the output of both usersGetCurrentAccount and sharingGetSharedLinkMetadata, as well as the shared link itself. You can open an API ticket here if you'd prefer to share privately.

Re: Problem of uploading image to dropbox shared link using url

Explorer | Level 3

If the shared folder is empty then Is there any other way to get the full folder path when you have only input as a URL of the shared folder link?

 

I tried sharingGetSharedLinkMetadata many times but it's not providing the path. So I am unable to upload images to that shared folder.

 

I will open an API ticket.

 

Thank you.

 

 

Re: Problem of uploading image to dropbox shared link using url

Dropboxer

Even if the folder is empty, the folder itself would have a path, but again it would only be returned if the accounts match.

 

We'll look into it and follow up with you on your ticket.

Polls
Are you starting new work habits this year?

Work Smarter with Dropbox

The way we work is changing. Share and discover new ways to work smarter with Dropbox in our community.

Sound good? Let's get started.
Who's talking

Top contributors to this post

What do Dropbox user levels mean?
Need more support?