cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Announcements
What’s new: end-to-end encryption, Replay and Dash updates. Find out more about these updates, new features and more 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: 

Download shared file from shared link

Download shared file from shared link

DavidM27
Explorer | Level 4
Go to solution

Hello,

 

I'm building a web app using Dropbox API, that app may be use to share some files to people that does not have a dropbox, so I created a share link via the API and then I want those people to be able to download it directly from the app.
I need the file to be download in the app because the file has to be manipulated before being downlodable by the uer.
What I tried was to use the share link and make an XHR request with the share link replacing the query parameter ?dl=0 by ?dl=1.
Buty obvioulsy this can not work because dropbox does not let me download it because of the CORS policy.
Can you tell if it is possible to download a file without being connected to dropbox and directly from my web app ?

1 Accepted Solution

Accepted Solutions

Greg-DB
Dropbox Staff
Go to solution

Unfortunately I don't have a good solution to offer here. Using a shared link with the parameter modification is the best way to share read-only access to a file when the recipient doesn't have a Dropbox account. As you found though, these can't be requested programmatically in browser JavaScript due to the CORS policy.

 

Alternatively, you could have your server do the download first, and then pass the contents down to end-user's browser instead. This would come at the expense of extra server bandwidth consumption though.

View solution in original post

7 Replies 7

Greg-DB
Dropbox Staff
Go to solution

Unfortunately I don't have a good solution to offer here. Using a shared link with the parameter modification is the best way to share read-only access to a file when the recipient doesn't have a Dropbox account. As you found though, these can't be requested programmatically in browser JavaScript due to the CORS policy.

 

Alternatively, you could have your server do the download first, and then pass the contents down to end-user's browser instead. This would come at the expense of extra server bandwidth consumption though.

DavidM27
Explorer | Level 4
Go to solution

Thank you Greg for your reply.
As a workaround I tried to use the dl.dropboxusercontent.com redirect link but it does work only with file not with folder... So we'll have to find another solution.

 

eliotcole
Explorer | Level 4
Go to solution

Hi, @DavidM27 , you could use the cloud API functionality of the various cloud based automation programs out there like Power Automate (Flow), automate.io, zapier, etc.

 

There might be a limit for the file size (Google used to max out at 50MB) either on Dropbox or the other end of the equation.

 

Equally, instead of open-ended download, you could have your users use a local folder with something like Dropbox, and create an app to copy it to their specific folder, which will then sync to their local folder.

( this seems like a valid use of all the bricks in this lego set 😉 ... )

 

dgtal box
Explorer | Level 3
Go to solution

How can I make my server download first?

const file = createWriteStream(filePath);
https.get(fileURL, response => {
response.pipe(file);
file.on('finish', () => {
file.close();
resolve();
});
}).on('error', err => {
fs.unlink(filePath, () => reject(err)); // Delete the file asynchronously on error
});

The code works for other content links. but doesn't works for the dropbox link.
I tired dl=1, raw=1. But still it doesn't work.

All i got everytime are invalid files.

dgtalbox_0-1711948124738.png

 

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

Hi @dgtal box,

It's never good idea using temporary derivative of shared link. The issue here is that... it's temporary - that's why expires. Use either the shared link itself or supported modification only instead. 😉

Hope this helps.

dgtal box
Explorer | Level 3
Go to solution

I never used temporary derivative of shared link. I use just the shared link itself.

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

@dgtal box wrote:

...
All i got everytime are invalid files.

dgtalbox_0-1711948124738.png

 


Hm...🤔 What is that what you got? 🧐 Is it the shared link itself? Or... not exactly. 🙂 Where you copy it from in gedit?

If you want, you can clarify what's going on by posting some code snippet that'll let the issue reproduction. So, likely will be more clear where is your error. The code should use either calls to Dropbox SDK or direct HTTP posts using fetch or XMLHttpRequest (or the HTTP requests themself), so to be reproducible. Mask any private info like different tokens.

Need more support?
Who's talking

Top contributors to this post

  • User avatar
    Здравко Legendary | Level 20
  • User avatar
    dgtal box Explorer | Level 3
  • User avatar
    eliotcole Explorer | Level 4
What do Dropbox user levels mean?