s3m-core
The reusable S3 client and streaming engine behind the
s3m CLI (s3m.stream).
s3m-core is free of any command-line concerns, so other applications can embed
it to talk to S3-compatible object storage directly. It provides:
s3— the S3 client (S3),Credentials,Region, request signing (AWS SigV4), the S3 actions (put/get/list/delete/multipart/…), and a typed request [Error] you can match on programmatically.stream— resumable multipart uploads plus the compression (Zstandard) and encryption (ChaCha20-Poly1305) transfer pipelines.
Installation
The example below also uses tokio, secrecy, and anyhow directly, so add
those to your own crate as well:
(anyhow is only used here for the example's main return type — s3m-core
itself exposes the typed [Error] and does not require it.)
Usage
use ;
use GetObject;
use SecretString;
async
Errors are matchable — e.g. distinguish a missing object from an auth failure:
use Error;
Object Lock (WORM)
[ObjectLock] carries per-upload retention and legal-hold settings; pass it via
[RequestOptions::object_lock] and it is emitted as the x-amz-object-lock-*
headers on PutObject / CreateMultipartUpload. Enable Object Lock on the
bucket at creation with CreateBucket::new(acl, /* object_lock_enabled */ true).
use ;
let mut opts = new;
opts.object_lock = Some;
To manage Object Lock after upload, the crate exposes Get/PutObjectLockConfiguration
(bucket default retention), Get/PutObjectRetention, and Get/PutObjectLegalHold
under s3m_core::s3::actions, returning ObjectLockConfiguration / ObjectRetention
/ ObjectLegalHold from s3m_core::s3::responses.
License
BSD-3-Clause. See the main repository for the full
project, the s3m CLI, and documentation.