s3_helper_5.py 576 B

12345678910
  1. def upload(value, storage):
  2. access_key_id, secret_key, bucket_name, do_space_url, encryption_enabled = parse_bucket_url(storage)
  3. s3 = get_resource(access_key_id, secret_key)
  4. ### S3Transfer allows multi-part, call backs etc
  5. # http://boto3.readthedocs.io/en/latest/_modules/boto3/s3/transfer.html
  6. transfer = S3Transfer(s3.meta.client)
  7. if encryption_enabled:
  8. transfer.upload_file(value, bucket_name, do_space_url, value, extra_args={'ServerSideEncryption': 'AES256'})
  9. else:
  10. transfer.upload_file(value, bucket_name, do_space_url, value)