Appearance
AwsS3Connector
Upload, download, list, and delete objects in AWS S3 buckets. Supports optional session tokens for temporary credentials and an optional region parameter.
Credentials
| Credential | Where to get it |
|---|---|
access_key / secret_key | IAM → Users → Security credentials — create an access key for a user with S3 permissions |
session_token | Optional; issued with temporary credentials from STS or assumed roles. Use None for long-term IAM keys |
region | Bucket region in the S3 console |
Docs: Managing access keys for IAM users
Usage
python
from elsai_cloud.aws import AwsS3Connector
s3_client = AwsS3Connector(
access_key="your_access_key",
secret_key="your_secret_key",
session_token="your_session_token",
)
# With an explicit region
s3_client = AwsS3Connector(
access_key="your_access_key",
secret_key="your_secret_key",
session_token="your_session_token",
region="us-east-1",
)Constructor parameters:
| Parameter | Required | Description |
|---|---|---|
access_key | Yes | AWS access key ID |
secret_key | Yes | AWS secret access key |
session_token | Yes | AWS session token (use None for long-term credentials) |
region | No | AWS region (e.g. "us-east-1") |
Upload a file:
python
s3_client.upload_file_to_s3(
bucket_name="your_bucket_name",
s3_key="your_s3_key",
file_path="path/to/your/file.txt",
)Download a file:
python
s3_client.download_file_from_s3(
bucket_name="your_bucket_name",
file_name="your_s3_key",
download_path="path/to/download/file.txt",
)Delete a file:
python
s3_client.delete_file_from_s3(
bucket_name="your_bucket_name",
s3_key="your_s3_key",
)List objects in a folder:
python
objects = s3_client.list_objects_in_s3_folder(
bucket_name="your_bucket_name",
prefix="your_folder_path/",
)
print(objects)Download an entire folder:
python
s3_client.download_folder_from_s3(
bucket_name="your_bucket_name",
prefix="your_folder_path/",
download_dir="path/to/local/download/folder",
)