· 7 years ago · Aug 07, 2018, 06:54 AM
1import boto
2import boto.s3.connection
3
4access_key = "testkey"
5secret_key = "testsecret"
6endpoint = "s3.US.knakayam-ceph-c2.example.com"
7endport = 80
8
9
10boto.config.add_section('s3a')
11boto.config.set('s3a', 'use-sigv4', 'True')
12
13conn = boto.connect_s3(
14 aws_access_key_id = access_key,
15 aws_secret_access_key = secret_key,
16 host = endpoint,
17 port = endport,
18 is_secure=False,
19 calling_format = boto.s3.connection.OrdinaryCallingFormat(),
20 )
21
22bucket = conn.create_bucket(bucket_name)
23for bucket in conn.get_all_buckets():
24 print "{name}\t{created}".format(
25 name = bucket.name,
26 created = bucket.creation_date,
27)
28
29#key = bucket.new_key('hello.txt')
30#key.set_contents_from_string('Hello World!')
31
32for key in bucket.list():
33 print "{name}\t{size}\t{modified}".format(
34 name = key.name,
35 size = key.size,
36 modified = key.last_modified,
37 )