Created
March 24, 2016 20:12
-
-
Save clayg/e2501e6615d0a1eae4e8 to your computer and use it in GitHub Desktop.
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
import sys | |
from swiftclient.client import get_auth, put_container, put_object | |
import httplib | |
import urlparse | |
def get_object(url, token, container, name): | |
""" | |
We're going to say we're going to upload 64MiB, but we're really only | |
going to send 3 x 3MiB... trololololo | |
""" | |
parsed = urlparse.urlparse(url) | |
conn = httplib.HTTPConnection(parsed.hostname, parsed.port) | |
conn.connect() | |
path = '/'.join([parsed.path, container, name]) | |
conn.putrequest('GET', path) | |
conn.putheader('X-Auth-Token', token) | |
conn.endheaders() | |
resp = conn.getresponse() | |
for i in range(3): | |
resp.read(64 * 2 ** 10) | |
# see you later sucker! | |
conn.close() | |
def main(): | |
url, token = get_auth( | |
'http://127.0.0.1:8080/auth/v1.0', | |
'test:tester', | |
'testing', | |
) | |
policy_name = 'ec' | |
# policy_name = 'repl' | |
container = '%s-disconnect-test' % policy_name | |
name = 'liarliar' | |
put_container(url, token, container, headers={ | |
'X-Storage-Policy': policy_name}) | |
put_object(url, token, container, name, '\x00' * (10 * 2 ** 20)) | |
get_object(url, token, container, name) | |
print 'finished!' | |
if __name__ == "__main__": | |
sys.exit(main()) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment