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
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 Buckets:
Returns a list of all buckets owned by the authenticated sender of the request.
buckets = await s3_handler.list_bucket()
print(buckets)
Download File:
The Download_file method accepts a file download in the buckets

await s3_handler.download_file(
    file_name="test.txt",
    object_name="test.txt"
)
List Objects in a Bucket: The List object method shows list all object in the bucket
await s3_handler.list_objects(prefix="folder/")
print(objects)
Delete an Object:
The Delete object can delete the object in the bucket
await s3_handler.delete_object(
    object_name="test.txt"
)
Generate a Pre-Signed URL:
The method will generate_presigned_url for the account
await s3_handler.generate_presigned_url(
    object_name="test.txt",
    expiration=3600  # URL valid for 1 hour
)
print("Presigned URL:", url)