s3

Download zip
Author
Version
0.1.0
License
Apache-2.0
Last updated
3 months ago
Downloads
19

Dependencies

#hackwaly/s3

Async S3 client for MoonBit, built on moonbitlang/async/http.

This package supports the native backend.

///|
async fn example {
let client = @s3.Client(
@s3.Config("us-east-1", @s3.Credentials("AKIA...", "secret...")),
)
let object = client.get_object("my-bucket", "path/to/object.txt")
let body = object.body.read_all().text()
object.body.close()
println(body)
}

For MinIO or other S3-compatible services, use a custom endpoint and path-style addressing:

///|
let client = @s3.Client(
@s3.Config(
"us-east-1",
@s3.Credentials("minioadmin", "minioadmin"),
endpoint="http://127.0.0.1:9000",
endpoint_style=@s3.Path,
),
)

Implemented operations:

  • get_object
  • put_object
  • head_object
  • delete_object
  • list_objects_v2

ReadCloser

pub(open) trait ReadCloser :
Reader
{
fn close(Self) -> Unit
}

S3Error

pub suberror S3Error {
InvalidConfig(String)
InvalidInput(String)
InvalidResponse(String)
ServiceError(
Response
, String)
} derive(
Debug
)

Client

pub struct Client {
// private fields
}
fn Client::Client(config : Config) -> Client raise

Client::delete_object

async fn Client::delete_object(self : Client, bucket : String, key : String, options? : RequestOptions) ->
Response

Client::get_object

async fn Client::get_object(self : Client, bucket : String, key : String, options? : RequestOptions) -> ObjectResult

Client::head_object

async fn Client::head_object(self : Client, bucket : String, key : String, options? : RequestOptions) ->
Response

Client::list_objects_v2

async fn Client::list_objects_v2(self : Client, bucket : String, prefix? : String, delimiter? : String, continuation_token? : String, max_keys? : Int, options? : RequestOptions) -> ListObjectsV2Result

Client::put_object

async fn Client::put_object(self : Client, bucket : String, key : String, body : &
Data
, options? : RequestOptions) ->
Response

Config

pub struct Config {
// private fields
} derive(Eq,
Debug
)
fn Config::Config(region : String, credentials : Credentials, endpoint? : String, endpoint_style? : EndpointStyle) -> Config

Credentials

pub struct Credentials {
// private fields
} derive(Eq)
fn Credentials::Credentials(access_key_id : String, secret_access_key : String, session_token? : String) -> Credentials

EndpointStyle

pub(all) enum EndpointStyle {
VirtualHost
Path
} derive(Eq,
Debug
)

ListObjectsV2Result

pub struct ListObjectsV2Result {
is_truncated : Bool
next_continuation_token : String?
contents : Array[ListedObject]
common_prefixes : Array[String]
} derive(Eq,
Debug
)

ListedObject

pub struct ListedObject {
key : String
size : Int64
etag : String?
} derive(Eq,
Debug
)

ObjectResult

pub struct ObjectResult {
response :
Response

body : &ReadCloser
}

RequestOptions

pub struct RequestOptions {
// private fields
} derive(
Debug
)
fn RequestOptions::RequestOptions(headers? : Map[String, String], query? : Map[String, String], timestamp? : String, payload_hash? : String) -> RequestOptions

Powered by MoonBit

Site sourceReport issuePackagesBuild queueSkillsStatistics

© 2026 mooncakes.io