Created
February 11, 2016 19:18
-
-
Save steynovich/bbfe3057ba8ef89bb30d to your computer and use it in GitHub Desktop.
sigv4 multipart upload test script
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
import sys | |
import boto3 | |
from botocore.client import Config | |
session = boto3.session.Session() | |
client = session.client('s3', config=Config(signature_version='s3v4')) | |
bucket = 'my-bucket' | |
key = 'test.txt' | |
upload_data = bytes("Hello world\n") | |
size = sys.getsizeof(upload_data) | |
mpu = client.create_multipart_upload(Bucket=bucket, | |
Key=key) | |
part1 = client.upload_part(Bucket=bucket, | |
Key=key, | |
Body=upload_data, | |
UploadId=mpu['UploadId'], | |
PartNumber=1, | |
ContentLength=size) | |
partinfo = {'Parts':[{'ETag': part1['ETag'], 'PartNumber': 1}]} | |
complete = client.complete_multipart_upload(Bucket=bucket, | |
Key=key, | |
MultipartUpload=partinfo, | |
UploadId=mpu['UploadId']) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment