Skip to content

Instantly share code, notes, and snippets.

@nak3
Created August 7, 2018 06:48
Show Gist options
  • Save nak3/90b36fd571a757dc5a1096d94f9ff468 to your computer and use it in GitHub Desktop.
Save nak3/90b36fd571a757dc5a1096d94f9ff468 to your computer and use it in GitHub Desktop.
s3 create bucket
import boto
import boto.s3.connection
access_key = "testkey"
secret_key = "testsecret"
endpoint = "s3.US.knakayam-ceph-c2.example.com"
endport = 80
boto.config.add_section('s3a')
boto.config.set('s3a', 'use-sigv4', 'True')
conn = boto.connect_s3(
aws_access_key_id = access_key,
aws_secret_access_key = secret_key,
host = endpoint,
port = endport,
is_secure=False,
calling_format = boto.s3.connection.OrdinaryCallingFormat(),
)
bucket = conn.create_bucket(bucket_name)
for bucket in conn.get_all_buckets():
print "{name}\t{created}".format(
name = bucket.name,
created = bucket.creation_date,
)
#key = bucket.new_key('hello.txt')
#key.set_contents_from_string('Hello World!')
for key in bucket.list():
print "{name}\t{size}\t{modified}".format(
name = key.name,
size = key.size,
modified = key.last_modified,
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment