Skip to content

Instantly share code, notes, and snippets.

@dmurawsky
Created February 3, 2020 17:56
Show Gist options
  • Save dmurawsky/170c1c7c39d917eaa94e309d1edb5a11 to your computer and use it in GitHub Desktop.
Save dmurawsky/170c1c7c39d917eaa94e309d1edb5a11 to your computer and use it in GitHub Desktop.
Deno bulk image downloader
// 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