Created
February 3, 2020 17:56
-
-
Save dmurawsky/170c1c7c39d917eaa94e309d1edb5a11 to your computer and use it in GitHub Desktop.
Deno bulk image downloader
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// To Run: | |
// deno run --allow-read --allow-net --allow-write ./bulkImageDownload.ts | |
const ROOT_URL = 'https://www.example.com/images/'; | |
const imgs = [ 'image1.jpg', 'image2.jpg', 'image3.jpg', 'image4.jpg' ]; | |
const init = () => | |
Promise.all( | |
imgs.map((fileName) => | |
fetch(ROOT_URL + fileName).then((resp) => resp.arrayBuffer()).then((buffer) => { | |
return Deno.writeFile(`/Users/username/Downloads/${fileName}`, new Uint8Array(buffer)); | |
}) | |
) | |
); | |
init(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment