Skip to content

Instantly share code, notes, and snippets.

@zonca
Created Jan 25, 2019
Embed
What would you like to do?
#!/usr/bin/env python
import io, boto3
boto3.set_stream_logger(name='')
session = boto3.Session()
s3 = session.resource('s3',
aws_access_key_id="xxxxxxxxxxxxxxxxxxxxxxxxx",
aws_secret_access_key="xxxxxxxxxxxxxxxxxxxxxxxxxx",
endpoint_url='JETSTREAM_SWIFT_ENDPOINT')
print(list(s3.buckets.all()))
bucket = s3.create_bucket(Bucket='testbucket')
print(list(s3.buckets.all()))
bucket.upload_fileobj(Key='testobject',
Fileobj=io.BytesIO(b'Hello, world!'))
print(list(bucket.objects.all()))
key = bucket.Object('testobject')
print(key.get()['Body'].read())
key.delete()
bucket.delete()
print(list(s3.buckets.all()))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment