AWS S3 client surface for bucket/object storage operations, multipart uploads, S3 presigned URLs, and opaque bucket policy documents.
See awskit for the pure core and runtime adapter overview.
The public entrypoint is Awskit_s3. Implementation modules, XML codecs, request builders, and response parsers are private.
awskit-s3 provides an AWS S3 client surface for bucket and object storage applications:
put, get, head, delete, copy, list, metadata, tags, ranges, checksums, conditional requests, version IDs, and version listingsBucket policy operations use opaque JSON policy documents, which lets applications provision bucket-level access rules while keeping policy document construction in application code.
Object APIs are split into explicit layers:
ObjectObjectObject.Transfer in Unix-capable adapter packagesPrimitive operations never expose string bodies as the primary API. Request bodies and response body readers come from the selected runtime adapter.
Awskit_s3 contains pure types, S3 endpoint configuration, standalone presigned URL helpers, and the runtime functor.
Main modules:
Awskit_s3.Object — object types, options, metadata records, checksums, preconditions, object versioning, and object tagging result typesAwskit_s3.Bucket — bucket result types and bucket configuration recordsAwskit_s3.Multipart — multipart upload identifiers, parts, options, and result recordsAwskit_s3.Transfer — high-level upload/download options, limits, strategy results, and multipart transfer result recordsAwskit_s3.Presigned — pure presigned URL generationAwskit_s3.Policy — validated opaque bucket policy JSON payloadsAwskit_s3.Make — functor for wiring S3 operations to a custom Awskit.Runtime.S implementationAwskit_s3_sim provides a deterministic in-memory S3 implementation for tests. It implements the same synchronous S3 operation shape as runtime-backed clients and adds a controllable clock, store inspection, operation history, and fault injection.
Awskit_s3_eio provides a direct-style Eio adapter. Operations return plain results. It also exposes local-path helpers under Object.Transfer.
Awskit_s3_lwt provides a functor over Cohttp_lwt.S.Client. Operations return Lwt.t.
Awskit_s3_lwt_unix provides the ready-to-use Lwt + Unix adapter. It can read credentials and region from the standard AWS environment variables through the underlying awskit-lwt-unix runtime.
open Eio.Std
let run env =
Switch.run @@ fun sw ->
let credentials =
Awskit.Credentials.create_exn
~access_key_id:"AKIAIOSFODNN7EXAMPLE"
~secret_access_key:"wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY"
()
in
let region = Awskit.Region.of_string_exn "us-east-1" in
let s3 = Awskit_s3_eio.create ~sw ~env ~region ~credentials () in
match
Awskit_s3_eio.Object.put_string s3
~bucket:"my-bucket"
~key:"hello.txt"
"Hello, S3!"
with
| Ok _ -> ()
| Error err -> Fmt.epr "%a@." Awskit_s3.Error.pp errlet run () =
let open Lwt.Syntax in
match Awskit_s3_lwt_unix.create () with
| Error err ->
Lwt_io.eprintf "%s\n" (Awskit_s3.Error.to_string_hum err)
| Ok s3 ->
let* result =
Awskit_s3_lwt_unix.Object.get_as_string s3
~bucket:"my-bucket"
~key:"hello.txt"
~max_bytes:1_048_576L
()
in
match result with
| Ok (_info, body) -> Lwt_io.printl body
| Error err -> Lwt_io.eprintf "%a\n" Awskit_s3.Error.pp err