![Javascript download file from url on click](https://cdn1.cdnme.se/5447227/9-3/screenshot_5_64e62947ddf2b306ca76f796.jpg)
Now, as we have a file blob, we have two ways to download it. Blob goes firstĪs we already know what's a Blob, let's have a look at how to download any data just using JavaScript Blob API.Ĭonsider having a JSON format object which contains some application configurations: const configuration = įirstly we have to convert out configuration object into a Blob: const myBlobFile = new Blob( The Fileinterface is based on Blob, inheriting blob functionality and expanding it to support files on the user's system. Blobs can represent data that isn't necessarily in a JavaScript-native format.
![javascript download file from url on click javascript download file from url on click](https://wallpapers.org.es/wp-content/uploads/ktz/ciudad-del-futuro-2v9c633r783633hifstjii.jpg)
MDN says: The Blob object represents a blob, which is a file-like object of immutable, raw data they can be read as text or binary data or converted into a ReadableStream so its methods can be used for processing the data.
![javascript download file from url on click javascript download file from url on click](https://www.sourcecodester.com/sites/default/files/styles/medium/public/urloutput1_1.png)
However, the Blob API and the new File System Access API now allow us to easily and efficiently download any file using JavaScript with just a click of a button. In the past, if you needed to store data on your computer while working with JavaScript, you may have had to use server-side code or complex HTML.
![Javascript download file from url on click](https://cdn1.cdnme.se/5447227/9-3/screenshot_5_64e62947ddf2b306ca76f796.jpg)