Amazon S3 is a cloud storage service on AWS that lets you store different types of files, like photos, audio, and videos, as objects. It offers high scalability and security, making it easy to store and access any amount of data from anywhere, anytime. S3 also provides features like high availability, strong security, and smooth integration with other AWS services.

Example

To create the AWSHandler object creation with the aws credentials. The AWSS3Handler connects to an Amazon S3 bucket using access credentials (access key, secret key) and specifies a region and bucket name. It enables seamless interaction with S3 for tasks like uploading, downloading, and managing files.

s3_handler_test.py
import os

from superagentx_handlers.aws.s3 import AWSS3Handler


s3_handler = AWSS3Handler(
        aws_access_key_id=os.getenv("AWS_ACCESS_KEY_ID"),
        aws_secret_access_key=os.getenv("AWS_SECRET_ACCESS_KEY"),
        bucket_name="test",
        region_name="eu-central-1"
)

File Upload:
The upload_file method accepts a file name and an object name.

await s3_handler.upload_file(
    file_name="test.txt",
    object_name="test.txt"
)

List Bucket:
Returns a list of all buckets owned by the authenticated sender of the request.

await s3_handler.list_bucket()

Download File:
The download_file method accepts the names of the bucket and object to download and the filename to save the file to.

await s3_handler.download_file(
    file_name="test.txt",
    object_name="test.txt"
)