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