You might see that the Dropbox Community team have been busy working on some major updates to the Community itself! So, here is some info on what’s changed, what’s staying the same and what you can expect from the Dropbox Community overall.
Forum Discussion
mappingsupport
9 months agoNew member | Level 2
What link do I use to read a JPG with code?
I put a JPG on dropbox (in a subfolder) and I am trying to download that JPG using a javascript fetch command. My code works fine with JPGs hosted on various other servers including Google Drive.
My javascript code is using this link: https://www.dropbox.com/scl/fi/ea9go6nont63t556sy6o4/WA_Chiwaukum_big_open_topo.jpg?rlkey=m7girlv2c79sq98u0retjcs6e&dl=1
The purpose for downloading the JPG is so my code can use the cache API to save the JPG on the user's device. This is all part of the GeoJPG web app I developed for offline maps.
If I enter the above link into a browser tab then I am invited to download the JPG. However, when I try to download the JPG content with my javascript then the following error messages show up in the browser's console.
Failed to load ‘https://www.dropbox.com/scl/fi/ea9go6nont63t556sy6o4/WA_Chiwaukum_big_open_topo.jpg?rlkey=m7girlv2c79sq98u0retjcs6e&dl=1’. A ServiceWorker passed a promise to FetchEvent.respondWith() that rejected with ‘TypeError: NetworkError when attempting to fetch resource.’.
Cross-Origin Request Blocked: The Same Origin Policy disallows reading the remote resource at https://www.dropbox.com/scl/fi/ea9go6nont63t556sy6o4/WA_Chiwaukum_big_open_topo.jpg?rlkey=m7girlv2c79sq98u0retjcs6e&dl=1. (Reason: CORS request did not succeed). Status code: (null).
What am I missing?
The www.dropbox.com website does not allow CORS requests, so attempting to access that from browser JavaScript will fail like that. There's also some information and options on these links here.
Alternatively, if you want to programmatically download content from a shared link in JavaScript, you can instead use the Dropbox JavaScript SDK. In particular, the sharingGetSharedLinkFile method allows an app to specify a shared link URL and get the linked file data back.
- Greg-DBDropbox Staff
The www.dropbox.com website does not allow CORS requests, so attempting to access that from browser JavaScript will fail like that. There's also some information and options on these links here.
Alternatively, if you want to programmatically download content from a shared link in JavaScript, you can instead use the Dropbox JavaScript SDK. In particular, the sharingGetSharedLinkFile method allows an app to specify a shared link URL and get the linked file data back.
About Dropbox API Support & Feedback
Find help with the Dropbox API from other developers.
5,888 PostsLatest Activity: 14 hours agoIf 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!