Dataset Image Downloader & Uploader avatar
Dataset Image Downloader & Uploader
Try for free

No credit card required

View all Actors
Dataset Image Downloader & Uploader

Dataset Image Downloader & Uploader

lukaskrivka/images-download-upload
Try for free

No credit card required

Download image files from image URLs in your datasets and save them to a Zip file, Key-Value store, or directly your AWS S3 bucket.

The code examples below show how to run the Actor and get its results. To run the code, you need to have an Apify account. Replace <YOUR_API_TOKEN> in the code with your API token, which you can find under Settings > Integrations in Apify Console. Learn mode

Node.js

Python

curl

1import { ApifyClient } from 'apify-client';
2
3// Initialize the ApifyClient with your Apify API token
4const client = new ApifyClient({
5    token: '<YOUR_API_TOKEN>',
6});
7
8// Prepare Actor input
9const input = {
10    "pathToImageUrls": "images",
11    "fileNameFunction": ({url, md5}) => md5(url),
12    "uploadTo": "zip-file",
13    "preDownloadFunction": `/* Example: We get rid of the items with price 0
14        ({ data }) => data.filter((item) => item.price > 0)
15        */`,
16    "postDownloadFunction": `/* Example: We remove items without any successfully uploaded images.
17         We also remove any image URLs that were not uploaded
18         
19         ({ data, state }) => {
20            return data.reduce((newData, item) => {
21                const downloadedImages = item.images.filter((imageUrl) => {
22                    return state[imageUrl] && state[imageUrl].imageUploaded;
23                });
24                
25                if (downloadedImages.length === 0) {
26                    return newData;
27                }
28                
29                return newData.concat({ ...item, images: downloadedImages });
30            }, []);
31        }
32        */`,
33    "imageCheckType": "content-type",
34    "proxyConfiguration": {
35        "useApifyProxy": true
36    }
37};
38
39(async () => {
40    // Run the Actor and wait for it to finish
41    const run = await client.actor("lukaskrivka/images-download-upload").call(input);
42
43    // Fetch and print Actor results from the run's dataset (if any)
44    console.log('Results from dataset');
45    const { items } = await client.dataset(run.defaultDatasetId).listItems();
46    items.forEach((item) => {
47        console.dir(item);
48    });
49})();
Developer
Maintained by Apify
Actor metrics
  • 14 monthly users
  • 97.6% runs succeeded
  • 10.7 days response time
  • Created in Nov 2018
  • Modified 27 days ago