Download from URL
The Download from URL method allows users to provide a direct link to a file, which will then be downloaded and added to the file list in the uploader.
â
Validations After Download
Unlike the drag-and-drop or file picker methods, validations for file type, size, are applied after the file is downloaded. This is necessary because the system can only analyze a fileâs format and weight once the file data is available.
If the downloaded file doesnât meet the rules youâve defined, the uploader will:
Reject the file.
Trigger the
onError
callback with the appropriate error code and message. đ See the list of error codes
â ď¸ CORS Warnings â Explained Simply
Imagine you're trying to grab a cookie from your neighborâs house through their window, but they only give cookies to people who come in through the front door.
Thatâs how CORS (Cross-Origin Resource Sharing) works.
When your app tries to download a file from another website, it's like trying to get something from someone elseâs house. The server (the neighbor) checks:
âWhoâs asking?â
âIs this person allowed to get this file?â
If the server doesnât explicitly allow files to be downloaded from your appâs location (origin), the request gets blocked by CORS, and the download will fail.
đŻ Example: When CORS blocks the download
Letâs say you see a nice banner on a site like somesite.com/banner.jpg
. You copy that imageâs URL and paste it into the uploader.
If somesite.com
only allows downloads when users are browsing their site, your request will be blocked.
That means: âSorry, you canât download this file unless youâre inside this site.â
â
Example: When CORS allows the download
Now try a file from a site like imgur.com:
https://i.imgur.com/CS0cI1d_lq.mp4
This file will download just fine because Imgur allows downloads from any app or website. That means their server doesnât block you based on where youâre requesting from. In CORS terms: "no restrictions".
Last updated