
From: Js zip files and download
| Download hp d1660 driver | Wii mod games download |
| Usb mtp driver for xp pro download | Css link to download file |
| Wakfu file download size | Street fighter 2 for pc free download |
Js zip files and download - have
Downloading remote images as a zip file using JSZip
Imagine this scenario where there is a gallery of images showing up on your website and you want the user to be able to select multiple images and download them as a zip file. How would you go about implementing it?
Firstly, we will have to fetch the images that are to be downloaded. We will be using browsers Fetch API to achieve that. Simple Enough?
Everything goes great until you stumble upon this CORS error.
To solve this you need to change the s3 bucket CORS settings. Add this to the file.
Alright! going back to creating the zip file. We are going to use a npm package called JSZip which will be responsible for generating a zip, and another one called file Saver that will trigger the download file for us.
And we are done. If you wanted to add multiple images then you could loop over the urls, fetch the image add it to the folder and finally generate a zip file.
-
-
-