I want to save in S3 from Amazon an image that I resize with Pillow. That image is uploaded by the user and I will upload it once resized. That is, it does not exist in S3.
Currently I’m doing it as follows:
Being a list of Pillow objects
def upload_s3(files): for f in files: print(f) path = default_storage.save('/test/cualquiersa/') f.save(path, "png")
You can use
boto3 to upload files to s3.
import boto3 client = boto3.client('s3') # For more client configuration http://boto3.readthedocs.io/en/latest/ def upload_s3(files): for f in files: print(f) response = client.put_object( Body= f, Bucket=<bucket_name>, Key=<location/directory> ) # More code here