Functions

abort-multipart-upload alias of ::aws::s3::objects/abort-multipart-upload

fn (bucket: Str, key: Str, upload_id: Str, opts: Map): Bool | ::aws::core/AwsError
fn (bucket: Str, key: Str, upload_id: Str): Bool | ::aws::core/AwsError

Abort a multipart upload and free the parts uploaded so far. Returns true.

Example

upload ::aws::s3::objects/create-multipart-upload("my-bucket", "video.mp4", "video/mp4")
::aws::s3::objects/abort-multipart-upload("my-bucket", "video.mp4", upload.upload_id)

complete-multipart-upload alias of ::aws::s3::objects/complete-multipart-upload

fn (bucket: Str, key: Str, upload_id: Str, parts: Vec, opts: Map): CompleteMultipartUploadResponse | ::aws::core/AwsError
fn (bucket: Str, key: Str, upload_id: Str, parts: Vec): CompleteMultipartUploadResponse | ::aws::core/AwsError

Finish a multipart upload, assembling the parts into the object. parts are the results of upload-part, or {part_number, etag} Maps. S3 can answer 200 and then report a failure in the body; that comes back as an err(AwsError) like any other.

Example

upload ::aws::s3::objects/create-multipart-upload("my-bucket", "video.mp4", "video/mp4")
part-1 ::aws::s3::objects/upload-part("my-bucket", "video.mp4", upload.upload_id, 1, Bytes("first chunk"))
part-2 ::aws::s3::objects/upload-part("my-bucket", "video.mp4", upload.upload_id, 2, Bytes("last chunk"))

result ::aws::s3::objects/complete-multipart-upload("my-bucket", "video.mp4", upload.upload_id, [part-1, part-2])
result.etag

copy-object alias of ::aws::s3::objects/copy-object

fn (source_bucket: Str, source_key: Str, dest_bucket: Str, dest_key: Str, opts: Map): CopyObjectResponse | ::aws::core/AwsError
fn (source_bucket: Str, source_key: Str, dest_bucket: Str, dest_key: Str): CopyObjectResponse | ::aws::core/AwsError

Copy an object within S3. Can copy between buckets or within the same bucket.

Example

// Copy within the same bucket
::aws::s3::objects/copy-object("my-bucket", "original.txt", "my-bucket", "backup.txt")

// Copy to a different bucket
::aws::s3::objects/copy-object("source-bucket", "file.txt", "dest-bucket", "file.txt")

create-bucket alias of ::aws::s3::buckets/create-bucket

fn (bucket: Str, region: Str, opts: Map): CreateBucketResponse | ::aws::core/AwsError
fn (bucket: Str, opts: Map): CreateBucketResponse | ::aws::core/AwsError
fn (bucket: Str, region: Str): CreateBucketResponse | ::aws::core/AwsError
fn (bucket: Str): CreateBucketResponse | ::aws::core/AwsError

Create a new S3 bucket.

Example

result ::aws::s3::buckets/create-bucket("my-new-bucket", "us-east-1")
result.location  // => "http://my-new-bucket.s3.amazonaws.com/"

// Use default region from context
result ::aws::s3::buckets/create-bucket("my-new-bucket")

create-multipart-upload alias of ::aws::s3::objects/create-multipart-upload

fn (bucket: Str, key: Str, content_type: Str, opts: Map): CreateMultipartUploadResponse | ::aws::core/AwsError
fn (bucket: Str, key: Str, opts: Map): CreateMultipartUploadResponse | ::aws::core/AwsError
fn (bucket: Str, key: Str, content_type: Str): CreateMultipartUploadResponse | ::aws::core/AwsError
fn (bucket: Str, key: Str): CreateMultipartUploadResponse | ::aws::core/AwsError

Start a multipart upload and get its upload_id. Upload the parts with upload-part, then finish with complete-multipart-upload, or give up with abort-multipart-upload: parts of an unfinished upload are stored and billed until it is completed or aborted.

Example

upload ::aws::s3::objects/create-multipart-upload("my-bucket", "video.mp4", "video/mp4")

part-1 ::aws::s3::objects/upload-part("my-bucket", "video.mp4", upload.upload_id, 1, Bytes("first chunk"))
part-2 ::aws::s3::objects/upload-part("my-bucket", "video.mp4", upload.upload_id, 2, Bytes("last chunk"))

::aws::s3::objects/complete-multipart-upload("my-bucket", "video.mp4", upload.upload_id, [part-1, part-2])

delete-bucket alias of ::aws::s3::buckets/delete-bucket

fn (bucket: Str, opts: Map): Bool | ::aws::core/AwsError
fn (bucket: Str): Bool | ::aws::core/AwsError

Delete an S3 bucket. The bucket must be empty before it can be deleted.

Example

::aws::s3::buckets/delete-bucket("my-bucket")
// => true

delete-object alias of ::aws::s3::objects/delete-object

fn (bucket: Str, key: Str, opts: Map): DeleteObjectResponse | ::aws::core/AwsError
fn (bucket: Str, key: Str): DeleteObjectResponse | ::aws::core/AwsError

DELETE an object from S3.

Example

::aws::s3::objects/delete-object("my-bucket", "path/to/file.txt")

generate-presigned-delete-url alias of ::aws::s3::presigned/generate-presigned-delete-url

fn (bucket: Str, key: Str, expires_in: Int, opts: Map): Str
fn (bucket: Str, key: Str, opts: Map): Str
fn (bucket: Str, key: Str, expires_in: Int): Str
fn (bucket: Str, key: Str): Str

Generate a presigned URL for deleting an S3 object.

The URL allows temporary delete access without credentials. expires_in is in seconds (default 3600 = 1 hour, max 604800 = 7 days).

Example

url ::aws::s3::presigned/generate-presigned-delete-url("my-bucket", "path/to/file.txt", 3600)

generate-presigned-upload-url alias of ::aws::s3::presigned/generate-presigned-upload-url

fn (bucket: Str, key: Str, expires_in: Int, opts: Map): Str
fn (bucket: Str, key: Str, opts: Map): Str
fn (bucket: Str, key: Str, expires_in: Int): Str
fn (bucket: Str, key: Str): Str

Generate a presigned URL for uploading an S3 object.

The URL allows temporary upload access without credentials. expires_in is in seconds (default 3600 = 1 hour, max 604800 = 7 days).

Example

// Generate a 1-hour upload URL
url ::aws::s3::presigned/generate-presigned-upload-url("my-bucket", "uploads/file.txt", 3600)

// Upload using the presigned URL (no AWS credentials needed)
::http ::hot::http
::http/put(url, "File content here")

generate-presigned-url alias of ::aws::s3::presigned/generate-presigned-url

fn (bucket: Str, key: Str, expires_in: Int, opts: Map): Str
fn (bucket: Str, key: Str, opts: Map): Str
fn (bucket: Str, key: Str, expires_in: Int): Str
fn (bucket: Str, key: Str): Str

Generate a presigned URL for downloading an S3 object.

The URL allows temporary access to the object without credentials. expires_in is in seconds (default 3600 = 1 hour, max 604800 = 7 days).

Example

// Generate a 1-hour download URL
url ::aws::s3::presigned/generate-presigned-url("my-bucket", "path/to/file.pdf", 3600)
// => "https://my-bucket.s3.us-east-1.amazonaws.com/path/to/file.pdf?X-Amz-Algorithm=..."

// Download using the presigned URL (no AWS credentials needed)
::http ::hot::http
response ::http/get(url)
response.body  // => file contents

get-object alias of ::aws::s3::objects/get-object

fn (bucket: Str, key: Str, opts: Map): GetObjectResponse | ::aws::core/AwsError
fn (bucket: Str, key: Str): GetObjectResponse | ::aws::core/AwsError

GET an object from S3.

Example

result ::aws::s3::objects/get-object("my-bucket", "path/to/file.txt")
result.body  // => "Hello!"

body is decoded: text as a Str, JSON parsed. For a binary object, or to get the stored bytes exactly, read body-bytes.

head-bucket alias of ::aws::s3::buckets/head-bucket

fn (bucket: Str, opts: Map): HeadBucketResponse | ::aws::core/AwsError
fn (bucket: Str): HeadBucketResponse | ::aws::core/AwsError

HEAD a bucket to check if it exists and get its region.

Example

result ::aws::s3::buckets/head-bucket("my-bucket")
result.exists  // => true

head-object alias of ::aws::s3::objects/head-object

fn (bucket: Str, key: Str, opts: Map): HeadObjectResponse | ::aws::core/AwsError
fn (bucket: Str, key: Str): HeadObjectResponse | ::aws::core/AwsError

HEAD an object to get metadata without downloading the body.

Example

result ::aws::s3::objects/head-object("my-bucket", "data.json")
result.content_type  // => "application/json"
result.etag          // => "\"d41d8cd98f00b204e9800998ecf8427e\""

list-buckets alias of ::aws::s3::buckets/list-buckets

fn (opts: Map): ListBucketsResponse | ::aws::core/AwsError
fn (): ListBucketsResponse | ::aws::core/AwsError

List all S3 buckets in the account.

Example

result ::aws::s3::buckets/list-buckets()
result.buckets
// => [{name: "my-bucket", creation_date: "2024-01-01T00:00:00Z"}, ...]

list-objects alias of ::aws::s3::objects/list-objects

fn (bucket: Str, prefix: Str?, max_keys: Int, continuation_token: Str?, opts: Map): ListObjectsResponse | ::aws::core/AwsError
fn (bucket: Str, prefix: Str?, max_keys: Int, opts: Map): ListObjectsResponse | ::aws::core/AwsError
fn (bucket: Str, prefix: Str?, opts: Map): ListObjectsResponse | ::aws::core/AwsError
fn (bucket: Str, opts: Map): ListObjectsResponse | ::aws::core/AwsError
fn (bucket: Str, prefix: Str?, max_keys: Int, continuation_token: Str?): ListObjectsResponse | ::aws::core/AwsError
fn (bucket: Str, prefix: Str?, max_keys: Int): ListObjectsResponse | ::aws::core/AwsError
fn (bucket: Str, prefix: Str?): ListObjectsResponse | ::aws::core/AwsError
fn (bucket: Str): ListObjectsResponse | ::aws::core/AwsError

List objects in an S3 bucket using the ListObjectsV2 API.

Supports pagination via continuation_token. When is_truncated is true, use next_continuation_token for the next request.

Example

// List objects with a prefix
result ::aws::s3::objects/list-objects("my-bucket", "uploads/", 10)
result.name      // => "my-bucket"
result.contents  // => [{key: "uploads/file1.txt", size: 1024, ...}, ...]

// List all objects in a bucket
result ::aws::s3::objects/list-objects("my-bucket")

// One "folder" level: keys under photos/, and the next level as common_prefixes
result ::aws::s3::objects/list-objects("my-bucket", "photos/", {delimiter: "/"})
result.common_prefixes  // => ["photos/2024/", "photos/2025/"]

opts takes delimiter and start-after besides the usual resolve keys.

put-object alias of ::aws::s3::objects/put-object

fn (bucket: Str, key: Str, body: Any, content_type: Str, opts: Map): PutObjectResponse | ::aws::core/AwsError
fn (bucket: Str, key: Str, body: Any, opts: Map): PutObjectResponse | ::aws::core/AwsError
fn (bucket: Str, key: Str, body: Any, content_type: Str): PutObjectResponse | ::aws::core/AwsError
fn (bucket: Str, key: Str, body: Any): PutObjectResponse | ::aws::core/AwsError

PUT an object to S3.

Example

// Upload text content
::aws::s3::objects/put-object("my-bucket", "path/to/file.txt", "Hello!", "text/plain")

// Upload JSON
data to-json({name: "Alice", active: true})
::aws::s3::objects/put-object("my-bucket", "data.json", data, "application/json")

to-doc-file alias of ::aws::s3::objects/to-doc-file

fn (object: Any, bucket: Str?): DocFile
fn (object: Any): DocFile

Normalise an S3Object (or a Map with key, size, last_modified, etag, and optionally content_type) into a DocFile. Pass bucket to fill drive-id. head-object and get-object results don't carry the key, so add it: to-doc-file({...untype(head), key: key}).

Example

listing ::aws::s3::objects/list-objects("my-bucket", "reports/")
files map(listing.contents, ::aws::s3::objects/to-doc-file(%, "my-bucket"))

to-doc-files alias of ::aws::s3::objects/to-doc-files

fn (listing: ListObjectsResponse): Vec

Every entry of a ListObjectsResponse as DocFiles: the objects, then the common_prefixes as folders. drive-id is the listing's bucket.

Example

listing ::aws::s3::objects/ListObjectsResponse({
  name: "my-bucket",
  contents: [::aws::s3::objects/S3Object({key: "reports/q3.pdf"})],
  common_prefixes: ["reports/archive/"]
})
map(::aws::s3::objects/to-doc-files(listing), %.name)  // ["q3.pdf", "archive"]

upload-part alias of ::aws::s3::objects/upload-part

fn (bucket: Str, key: Str, upload_id: Str, part_number: Int, body: Str | Bytes, opts: Map): UploadPartResponse | ::aws::core/AwsError
fn (bucket: Str, key: Str, upload_id: Str, part_number: Int, body: Str | Bytes): UploadPartResponse | ::aws::core/AwsError

Upload one part of a multipart upload. part_number is 1 to 10000. Every part except the last must be at least 5 MiB. Send Bytes for binary data.

Example

upload ::aws::s3::objects/create-multipart-upload("my-bucket", "video.mp4", "video/mp4")
part ::aws::s3::objects/upload-part("my-bucket", "video.mp4", upload.upload_id, 1, Bytes("first chunk"))
part.etag  // keep this for complete-multipart-upload

Types

AwsError alias of ::aws::core/AwsError

CompleteMultipartUploadResponse alias of ::aws::s3::objects/CompleteMultipartUploadResponse

CompleteMultipartUploadResponse type {
    location: Str?,
    bucket: Str?,
    key: Str?,
    etag: Str?
}

CopyObjectResponse alias of ::aws::s3::objects/CopyObjectResponse

CopyObjectResponse type {
    etag: Str?,
    last_modified: Str?
}

CreateMultipartUploadResponse alias of ::aws::s3::objects/CreateMultipartUploadResponse

CreateMultipartUploadResponse type {
    bucket: Str?,
    key: Str?,
    upload_id: Str?
}

Credentials alias of ::aws::core/Credentials

DocFile alias of ::aws::s3::objects/DocFile

DocFile type {
    provider: Str,
    id: Str,
    name: Str,
    mime-type: Str,
    path: Str?,
    size: Int?,
    modified: Str?,
    created: Str?,
    parents: Vec,
    drive-id: Str?,
    web-url: Str?,
    version: Str?,
    revision-id: Str?,
    md5: Str?,
    sha256: Str?,
    is-folder: Bool,
    is-google-native: Bool,
    is-shortcut: Bool,
    shortcut-target-id: Str?,
    trashed: Bool,
    export-formats: Vec,
    raw: Map
}

Provider-neutral file metadata: the field names of ::google::drive/DocFile, plus path, so a documents package can treat S3 like Drive, Dropbox, Box and OneDrive.

Fields

  • provider - "aws-s3"
  • id, path - the object key
  • name - the last path segment of the key
  • mime-type - the stored type when known, else from the key's extension (application/octet-stream when unknown; inode/directory for folders)
  • size, modified
  • created - always null; S3 doesn't record it apart from modified
  • parents - the key's parent prefix, empty at the top of the bucket
  • drive-id - the bucket, when known
  • web-url, revision-id, md5, sha256, shortcut-target-id - always null (an ETag is only sometimes an MD5)
  • version - the ETag, without its quotes
  • is-folder - the key ends in /
  • is-google-native, is-shortcut, trashed - always false
  • export-formats - always empty
  • raw - what was normalised

GetObjectResponse alias of ::aws::s3::objects/GetObjectResponse

GetObjectResponse type {
    body: Any,
    body-bytes: Bytes?,
    content_type: Str?,
    content_length: Int?,
    etag: Str?,
    last_modified: Str?
}

ListObjectsResponse alias of ::aws::s3::objects/ListObjectsResponse

ListObjectsResponse type {
    name: Str?,
    prefix: Str?,
    key_count: Int?,
    max_keys: Int?,
    is_truncated: Bool?,
    continuation_token: Str?,
    next_continuation_token: Str?,
    start_after: Str?,
    contents: Vec<S3Object>?,
    delimiter: Str?,
    common_prefixes: Vec<Str>?
}

PutObjectResponse alias of ::aws::s3::objects/PutObjectResponse

PutObjectResponse type {
    etag: Str?,
    version_id: Str?
}

S3Bucket alias of ::aws::s3::buckets/S3Bucket

S3Bucket type {
    name: Str,
    creation_date: Str?
}

S3Object alias of ::aws::s3::objects/S3Object

S3Object type {
    key: Str,
    size: Int?,
    last_modified: Str?,
    etag: Str?,
    storage_class: Str?
}

UploadPartResponse alias of ::aws::s3::objects/UploadPartResponse

UploadPartResponse type {
    part_number: Int,
    etag: Str?
}