Skip to content

Instantly share code, notes, and snippets.

@joseph-zhong
Created December 22, 2016 22:37
Show Gist options
  • Save joseph-zhong/b7265bcfaeaf82a49b2c57e0d270f6c7 to your computer and use it in GitHub Desktop.
Save joseph-zhong/b7265bcfaeaf82a49b2c57e0d270f6c7 to your computer and use it in GitHub Desktop.
Boto3 Multipart upload
total_bytes = os.stat('path/to/file').st_size
PROGRESS_BYTES = 0
def upload_callback(bytes, progress_bytes=PROGRESS_BYTES):
  progress_bytes += bytes
  sys.stdout.write('\r')
  sys.stdout.write('part uploaded: %d of %d bytes' % (progress_bytes, total_bytes))
  sys.stdout.flush()

with open(output_file, 'rb') as ouput_data:
  s3.upload_fileobj(ouput_data, s3_bucket, s3_key, Callback=upload_callback)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment