How do I go about setting ContentType on images that I upload to AWS S3 using boto3 to content-type:image/jpeg?
Currently, I upload images to S3 using buto3/python 2.7 using the following command:
s3.upload_fileobj(bytes_io_file, bucket_name, filename)
However, to set the uploaded object's type to ContentType= 'image/jpeg', I have to manually select all 'folders' on S3 through the web interface, and set metadata to Content-type : Image/jpeg
Is there a way to set this flag in the upload request i have above?
Thank you in advance!
Add it in the ExtraArgs
argument:
s3.upload_fileobj(bytes_io_file, bucket_name, filename, ExtraArgs={ "ContentType": "image/jpeg"})
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With