![Dataset Image Downloader & Uploader avatar](https://images.apifyusercontent.com/b5NwTFraUgZet4xT3vWkIOA0WSqiB137VoB-LhdloeE/rs:fill:250:250/aHR0cHM6Ly9hcGlmeS1pbWFnZS11cGxvYWRzLXByb2QuczMuYW1hem9uYXdzLmNvbS9TRVFCbkVBNW9lMlI5SGdkai9SU1JBR3REZ1htV21kNFkzNS1qcGcuanBn.webp)
Dataset Image Downloader & Uploader
Try for free
No credit card required
View all Actors![Dataset Image Downloader & Uploader](https://images.apifyusercontent.com/b5NwTFraUgZet4xT3vWkIOA0WSqiB137VoB-LhdloeE/rs:fill:250:250/aHR0cHM6Ly9hcGlmeS1pbWFnZS11cGxvYWRzLXByb2QuczMuYW1hem9uYXdzLmNvbS9TRVFCbkVBNW9lMlI5SGdkai9SU1JBR3REZ1htV21kNFkzNS1qcGcuanBn.webp)
![Dataset Image Downloader & Uploader](https://images.apifyusercontent.com/b5NwTFraUgZet4xT3vWkIOA0WSqiB137VoB-LhdloeE/rs:fill:250:250/aHR0cHM6Ly9hcGlmeS1pbWFnZS11cGxvYWRzLXByb2QuczMuYW1hem9uYXdzLmNvbS9TRVFCbkVBNW9lMlI5SGdkai9SU1JBR3REZ1htV21kNFkzNS1qcGcuanBn.webp)
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.
Do you want to learn more about this Actor?
Get a demoThe 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 more
1from apify_client import ApifyClient
2
3# Initialize the ApifyClient with your Apify API token
4client = ApifyClient("<YOUR_API_TOKEN>")
5
6# Prepare the Actor input
7run_input = {
8 "pathToImageUrls": "images",
9 "fileNameFunction": "({url, md5}) => md5(url)",
10 "uploadTo": "zip-file",
11 "preDownloadFunction": """/* Example: We get rid of the items with price 0
12({ data }) => data.filter((item) => item.price > 0)
13*/""",
14 "postDownloadFunction": """/* Example: We remove items without any successfully uploaded images.
15 We also remove any image URLs that were not uploaded
16
17 ({ data, state }) => {
18 return data.reduce((newData, item) => {
19 const downloadedImages = item.images.filter((imageUrl) => {
20 return state[imageUrl] && state[imageUrl].imageUploaded;
21 });
22
23 if (downloadedImages.length === 0) {
24 return newData;
25 }
26
27 return newData.concat({ ...item, images: downloadedImages });
28 }, []);
29}
30*/""",
31 "imageCheckType": "content-type",
32 "proxyConfiguration": { "useApifyProxy": True },
33}
34
35# Run the Actor and wait for it to finish
36run = client.actor("lukaskrivka/images-download-upload").call(run_input=run_input)
37
38# Fetch and print Actor results from the run's dataset (if there are any)
39print("💾 Check your data here: https://console.apify.com/storage/datasets/" + run["defaultDatasetId"])
40for item in client.dataset(run["defaultDatasetId"]).iterate_items():
41 print(item)
42
43# 📚 Want to learn more 📖? Go to → https://docs.apify.com/api/client/python/docs/quick-start
Developer
Maintained by Apify
Actor metrics
- 39 monthly users
- 10 stars
- 99.6% runs succeeded
- Created in Nov 2018
- Modified 3 months ago
Categories