Skip to content

Instantly share code, notes, and snippets.

@gamame
Forked from garnaat/boto_mpupload_1
Created April 2, 2012 10:44
Show Gist options
  • Save gamame/2282497 to your computer and use it in GitHub Desktop.
Save gamame/2282497 to your computer and use it in GitHub Desktop.
An IPython transcript showing use of S3 MultiPart Upload in boto
In [1]: import boto
In [2]: c = boto.connect_s3()
In [3]: b = c.lookup('test-1245812163')
In [4]: mp = b.initiate_multipart_upload('testmpupload2')
In [5]: mp
Out[5]: <MultiPartUpload testmpupload2>
In [6]: fp = open('xaa', 'rb')
In [7]: mp.upload_part_from_file(fp, 1)
In [8]: fp.close()
In [9]: fp = open('xab', 'rb')
In [10]: mp.upload_part_from_file(fp, 2)
In [11]: fp.close()
In [12]: fp = open('xac', 'rb')
In [13]: mp.upload_part_from_file(fp, 3)
In [14]: fp.close()
In [15]: fp = open('xad', 'rb')
In [16]: mp.upload_part_from_file(fp, 4)
In [17]: fp.close()
In [18]: for part in mp:
....: print part.part_number, part.size
....:
1 5242880
2 5242880
3 5242880
4 1505917
In [19]: mp.complete_upload()
In [20]:
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment