Created
December 12, 2014 11:24
-
-
Save JohnPreston/d4ecc997e99d233824ff to your computer and use it in GitHub Desktop.
SimpleS3Test
This file contains hidden or 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 boto | |
| from boto.s3.connection import OrdinaryCallingFormat | |
| import os | |
| import requests | |
| S3_HOST='10.105.10.30' | |
| connection = boto.connect_s3(is_secure=False, host=S3_HOST, port=8773, path="/services/objectstorage", calling_format=OrdinaryCallingFormat()) | |
| try: | |
| bucket = connection.create_bucket('test-noushe-740') | |
| except: | |
| bucket = connection.get_bucket('test-noushe-740') | |
| print "Ok for the bucket - now testing on the file" | |
| key = bucket.new_key('test.file') | |
| key.set_contents_from_string('testcontent') | |
| key.set_canned_acl('public-read') | |
| # this works with walrusbackend but not with RiakCS/Ceph | |
| headers = {'Range': 'bytes=4-'} | |
| res = requests.get('http://%s:8773/services/objectstorage/test-noushe-740/test.file' % S3_HOST, headers=headers) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment