Boto 3

Boto 3 is an Amazon Web Services SDK for Python, and provides an easy way to write code to interface with the USS S3 Gateway. The first example below shows how you can programmatically list all buckets within your USS S3 Gateway instance using the Boto 3 client interface (Boto 3 also offers a "resource" interface that provides higher-level access albeit with less control). The second example generates a "presigned" URL of a specific object that expires after 1 hour. The URL can be used to download (GET) the object. While the SDK supports many AWS services, only the S3 calls are relevant to the USS S3 Gateway. More examples and documentation can be found here:


#!/usr/bin/env python 

import boto3

session = boto3.session.Session()

s3_client = session.client(
	service_name='s3',
	aws_access_key_id='<username>',
	aws_secret_access_key='<password>',
	endpoint_url='<endpoint-url>'
)

buckets = s3_client.list_buckets()

print('My Buckets:')
for bucket in buckets['Buckets']:
	print(bucket)
#!/usr/bin/env python

import boto3

session = boto3.session.Session()
 
s3_client = session.client(
	service_name='s3',
	aws_access_key_id='<username>',
	aws_secret_access_key='<password>',
	endpoint_url='<endpoint-url'
)

presigned_url = s3_client.generate_presigned_url(
	'get_object',
	Params={'Bucket': 'mybucket', 'Key': 'my/prefix/myobject'},
	ExpiresIn=3600
)

print(presigned_url)