Skip to content Skip to sidebar Skip to footer

Save Image Data From A Iterator Object To Aws S3 In Python

I am calling an API that returns a iterator object containing image data. I'd like to iterate over them and upload to s3. I could either open them into .png or .jpeg before or afte

Solution 1:

This can be done by using the s3fs to save the image in png format.

I could recreate and achieve the sample using the below code:

from PIL import Image
import s3fs

s3=s3fs.S3FileSystem(client_kwargs=<aws_credentials>)


img_obj = Image.open('sample_file.png')
img_obj.save(s3.open('s3:///<bucket_name>/sample_file.png', 'wb'), 'PNG')

enter image description here

Post a Comment for "Save Image Data From A Iterator Object To Aws S3 In Python"