To install the Python library for this version that allows connection to the OpenCayle service, run:
pip install boto3
If you need more information on how to use this library: https://boto3.amazonaws.com/v1/documentation/api/1.35.29/guide/quickstart.html
To establish the connection with the OpenCAYLE server from a Python script, you will need to configure the following parameters as shown in the example below. If you do not have the indicated AccessKey, follow these steps to obtain the AccessKey.
s3 = boto3.resource('s3',
endpoint_url='https://ss3.scayle.es:443',
aws_access_key_id='AccessKey',
aws_secret_access_key='AccessKey',
config=Config(signature_version='s3v4')
)
To create a bucket, complete the following parameters:
s3.create_bucket(
Bucket="BucketName"
)
To list the buckets associated with your account:
for bucket in s3.buckets.all():
print(bucket.name)
To upload files to a bucket, complete the following parameters:
with open('PathOrigen', 'rb') as data:
s3.Bucket('BucketName').put_object(Key='PathDestino', Body=data)
To download files from a bucket, complete the following parameters:
s3.Bucket('BucketName').download_file('PathOrigen', 'PathDestino')
Last updated: 24/02/2025 11:37