| Crates.io | aws_utils_s3 |
| lib.rs | aws_utils_s3 |
| version | 0.3.0 |
| created_at | 2025-07-28 06:44:32.377107+00 |
| updated_at | 2025-09-16 23:43:06.180342+00 |
| description | AWS S3 utilities for common operations like listing, uploading, downloading, and deleting objects |
| homepage | https://github.com/UniqueVision/utilities.aws-utils |
| repository | https://github.com/UniqueVision/utilities.aws-utils |
| max_upload_size | |
| id | 1770779 |
| size | 90,504 |
A utility crate for AWS S3 client operations.
make_client_with_timeout_default - Create an S3 client with default timeout settingsmake_client_with_timeout - Create an S3 client with custom timeout settingsmake_client - Create an S3 client with optional endpoint URL and timeout configurationbucket::create_bucket - Create a new S3 bucketbucket::list_stream - Stream buckets with prefix filteringbucket::list_all - List all buckets matching a prefixbucket::delete_bucket - Delete a bucket and all its contentsbucket::delete_buckets - Delete multiple buckets matching a prefixobject::list_stream - Stream objects from an S3 bucket with optional prefixobject::list_all - Retrieve all objects from an S3 bucket at onceobject::get_object - Retrieve an objectobject::is_exists - Check if an object existsobject::get_object_string - Retrieve object content as a stringobject::get_object_buf_reader - Get object as a BufferedReaderobject::put_object - Upload an objectobject::put_object_from_path - Upload an object from a file pathobject::delete_object - Delete a single objectobject::delete_objects - Batch delete objects matching a prefixobject::copy_object - Copy an object between bucketsobject::copy_objects_prefix - Copy multiple objects matching a prefixpresigned::put_presigned - Generate a presigned URL for uploadspresigned::get_presigned - Generate a presigned URL for downloadspresigned::presigned_url - Extract URL string from PresignedRequestuse aws_utils_s3::{bucket, object, presigned, make_client_with_timeout_default};
// Create client with default timeout settings
let client = make_client_with_timeout_default(None).await;
// Bucket operations
bucket::create_bucket(&client, "my-bucket").await?;
let buckets = bucket::list_all(&client, "my-").await?;
bucket::delete_bucket(&client, "old-bucket").await?;
// List objects
let objects = object::list_all(&client, "my-bucket", Some("prefix/")).await?;
// Check if object exists
let exists = object::is_exists(&client, "my-bucket", "key.txt").await?;
// Get object
let object = object::get_object(&client, "my-bucket", "key.txt").await?;
let (content_type, content) = object::get_object_string(object).await?;
// Upload object
object::put_object(
&client,
"my-bucket",
"key.txt",
"Hello, World!",
Some("text/plain"),
None,
).await?;
// Upload from file
object::put_object_from_path(
&client,
"my-bucket",
"key.pdf",
"/path/to/file.pdf",
Some("application/pdf"),
None,
).await?;
// Copy object
object::copy_object(
&client,
"src-bucket",
"src-key.txt",
"dst-bucket",
"dst-key.txt",
).await?;
// Copy objects with prefix
object::copy_objects_prefix(
&client,
"src-bucket",
"src-prefix",
"dst-bucket",
"dst-prefix",
).await?;
// Generate presigned URL
let presigned = presigned::get_presigned(
&client,
"my-bucket",
"key.txt",
std::time::Duration::from_secs(3600),
).await?;
let url = presigned::presigned_url(&presigned);
// Batch delete objects with prefix
object::delete_objects(&client, "my-bucket", Some("temp/")).await?;
use aws_utils_s3::{make_client, make_client_with_timeout, make_client_with_timeout_default};
use std::time::Duration;
// Use default timeout settings (recommended)
let client = make_client_with_timeout_default(None).await;
// Use custom timeout settings
let client = make_client_with_timeout(
None, // endpoint_url
Some(Duration::from_secs(3100)), // connect_timeout
Some(Duration::from_secs(60)), // operation_timeout
Some(Duration::from_secs(55)), // operation_attempt_timeout
Some(Duration::from_secs(50)), // read_timeout
).await;
// Use custom endpoint with default timeout settings
let client = make_client_with_timeout_default(
Some("http://localhost:4566".to_string())
).await;
// Use legacy client without timeout configuration
let client = make_client(None, None).await;
// Use custom endpoint and no timeout (legacy)
let client = make_client(Some("http://localhost:4566".to_string()), None).await;
This crate provides an Error type that handles:
Helper methods for specific error checking:
is_no_such_key() - Check if object doesn't existis_no_such_bucket() - Check if bucket doesn't existdelete_objects processes in batches of 1000 (due to AWS S3 limitations)