Need to see if your shared folder is taking up space on your dropbox 👨‍💻? Find out how to check here.

Forum Discussion

dgtal box's avatar
dgtal box
Explorer | Level 3
2 years ago

Download files from shared link using javascript

...
await new Promise<void>((resolve, reject) => {
 const file = createWriteStream(filePath);
 https.get(createAudioLibraryCard.basicInfo.sharedLink, 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 above code downloads for other content links. 
a sample link as bellow:

https://st2.depositphotos.com/1743476/11581/i/950/depositphotos_115812486-stock-photo-pride-man-smiling.jpg
But, it doesn't download for a dropbox shared link.
https://www.dropbox.com/scl/fi/1exa5owhx97kozgshjx3d/1.png?rlkey=b5rtxqmcprjgfrqnkspgguwuy&dl=0

https://www.dropbox.com/scl/fi/1exa5owhx97kozgshjx3d/1.png?rlkey=b5rtxqmcprjgfrqnkspgguwuy&dl=1
https://www.dropbox.com/scl/fi/1exa5owhx97kozgshjx3d/1.png?rlkey=b5rtxqmcprjgfrqnkspgguwuy&dl=0&raw=1
https://www.dropbox.com/scl/fi/1exa5owhx97kozgshjx3d/1.png?rlkey=b5rtxqmcprjgfrqnkspgguwuy&dl=1&raw=1

 

So I'd like to ask if I can still download files from a shared link of dropbox to my local backend instance using javascript.

4 Replies

Replies have been turned off for this discussion
  • Здравко's avatar
    Здравко
    Legendary | Level 20
    2 years ago

    Hi again dgtal box,

    Yes, as mentioned in another thread here on the forum where you participate too, there are some issues with CORS. You still can request the pointed file with some tricks, like following:

    As you can see it's possible. Just change the domain as shown and that's it. The missing header, as in your case, here exists! By the way, you can just wipe out the ending "&dl=0", but it's not something mandatory.

    Hope this helps.

  • Здравко's avatar
    Здравко
    Legendary | Level 20
    2 years ago

    dgtal box wrote:

    ...
    Any solution for a folder?


    No, that trick doesn't work for folder links, unfortunately. Even if that works, you would need to unzip the content (a zip file would come up, not something else). You could walk through the particular folder tree and download all files while recreating the tree locally instead (like unzipping would do). 😉 Take a look here (shell example) for a possible solution (in your case would be much smaller - javascript has more tools). Just get the idea out of there. You may have some challenges with placing on/accessing local space out of the browser though.

    Good luck.

     

    Add: For one more solution targeting listing the pointed folder take a look here (it's in Python - just get idea out from there). 🙂 In such a case you don't need any application registration.

  • dgtal box's avatar
    dgtal box
    Explorer | Level 3
    2 years ago

    I would be a happy camper when I get a solution to get even a zip file from shared link for folder.

    The rest things don't matter.

About Dropbox API Support & Feedback

Node avatar for Dropbox API Support & Feedback
Find help with the Dropbox API from other developers.

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, Facebook or Instagram.

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!