Tips for new TMS Web Core developers and in particular for seasoned Delphi developers

Another solution to bypass CORS for your own files

If you have files you want to share, you don't want to put them on your own server account (maybe b/c you don't have one), and you're running into CORS issues with a script trying to access them elsewhere, there's a way to use Dropbox that has been around for a while but isn't very well-known.

First, I'll say that Dropbox has an advantage over lots of file-sharing sites in that you can access it in a few different ways:

  1. Directly on their Website
  2. Their app running in your OS so it looks like a normal folder
  3. Via their API (TMS Cloud Pack has an interface for it)

Also, their daily bandwith limitaions are absurdly high.

Basic [ie, "free"] accounts and accounts on a trial of a Dropbox team: 20 GB of bandwidth and 100,000 downloads per day .
Plus, Family, Standard, and Professional accounts: 1 TB and unlimited downloads per day.
Dropbox team Advanced and Enterprise accounts: 4 TB and unlimited downloads per day.

You can get hold of a link to post online from their website or their app and it looks like this:

https://www.dropbox.com/s/x12nrdio8i9oe52/sample-3s.mp3?dl=0

The querystring arg dl=0 can be changed to dl=1 for use in a browser to initiate a download rather than opening it up in the browser. But if you do that via a script, you'll get a CORS error.

So here's the secret: change the link to look like this:

https://dl.dropboxusercontent.com/s/x12nrdio8i9oe52/sample-3s.mp3

That is, change the domain name and remove the ?dl=0 querystring argument from the end of the URL.

This version runs in my WEB Core app while the earlier one gives a CORS error.

According to the whois record, the domain name dropboxusercontent.com is owned by Dropbox themselves, so it's not going to be intercepted by some unknown 3rd-party (which is I think how it got started). Searching Google for it shows a lot of complaints that it doesn't work, but most of them were from several years ago. Not much lately.

1 Like