Recipes for Cloud Platforms
import boto3
from botocore.client import Config
s3 = boto3.resource('s3',
endpoint_url='ENDPOINT_URL',
aws_access_key_id='AWS_ACCESS_KEY_ID',
aws_secret_access_key='AWS_SECRET_ACCESS_KEY',
config=Config(signature_version='s3v4'),
region_name='us-east-1')
bucket = s3.Bucket('mybucket')
[f for f in s3.buckets.all()]
[f for f in bucket.objects.all()]
bucket.upload_file('local_path', 'destination_name')
bucket.download_file('source_name', 'local_path')
You can use either:
from minio import Minio
client = Minio(endpoint='ENDPOINT_URL',
access_key='ACCESS_KEY',
secret_key='SECRET_KEY')
client.list_buckets()
client.list_objects('mybucket')
client.fput_object(bucket_name='mybucket',
object_name='destination_name',
file_path='local_path')
client.fget_object(bucket_name='mybucket',
object_name='source_name',
file_path='local_path')