Standard library · Web and services

aws

Amazon S3, SQS and STS, and any S3 compatible service, with Signature Version 4.

import aws

This package works with Amazon S3 and any storage compatible with it without the official SDK, including MinIO, Cloudflare R2, DigitalOcean Spaces, Wasabi, Backblaze and any other S3 compatible cloud storage. Build the configuration with ForAws or ForEndpoint and hand it the keys with WithCredentials, or let the package find them itself with FromEnvironment and ResolveConfig.

The S3... functions work with objects and buckets: writing and reading, listing, copying, files and folders, multipart uploads for large files, and presigned URLs so a browser can talk to S3 directly. The Sqs... functions cover SQS message queues and the AssumeRole... functions cover temporary STS credentials. For other services, such as DynamoDB, call any API with NewJsonCall and Invoke.

Use this package when a program stores files in object storage, hands out upload links, runs queue workers or calls another AWS API. It signs every request with Signature Version 4 itself and sends it over net.http, so it needs no SDK and no C library. For a plain HTTP API that is not AWS, use net.http directly.

Core ideas

•

Config. A Config is a plain value: endpoint, region, bucket, keys and whether the bucket goes in the path. Every call takes it first. Change it with the With... functions or by setting a field; nothing is global.

•

Results, not errors. Calls return a struct with ok, the HTTP status, AWS's error code and a readable error. A network failure (code is Transport), a 429 or a 5xx answer is tried again with a doubling pause, up to retry attempts in all (3 by default), before you see it.

•

Keys are names. S3 has no folders. reports/2026/may.csv is one key, and "folders" are prefixes you list by.

Things that trip people up

•

S3Get returns the body as a str, which stops at the first zero byte. For images, archives and other binary data use S3GetBytes or S3DownloadFile.

•

S3ListPrefix returns one page of at most 1000 keys. S3ListAll follows the pages for you, up to 100000 keys, and sets truncated when it stopped there. S3Keys returns an empty list when the listing failed, so it cannot tell "empty" from "error".

•

Configured also wants a bucket. A program that only uses SQS, STS or Invoke should check access_key and secret_key itself.

•

Lists hold memory of their own: free them with ListFree, KeyFree, MessageListFree, FreeBytes and the like.

Never write keys into your code; use environment variables or an IAM role. The examples that need an AWS account or a running MinIO are only checked on the site, not run.

One program, any S3 provider

Every provider speaks the same S3 API; what differs is the address, the region and whether the bucket goes in the path or in the host name. The For... functions fill those in, so the provider can be a setting of your program and the rest of the code never changes. R2 uses the region auto and path style addresses; AWS and Spaces put the bucket in the host name.

aws-guide-providers.salam
import aws

func storage(provider: str, bucket: str): aws.Config:
    switch provider:
        "r2":
            ret aws.ForR2("0123456789abcdef", bucket)
        end
        "spaces":
            ret aws.ForSpaces("ams3", bucket)
        end
        "minio":
            ret aws.ForMinio("http://127.0.0.1:9000", bucket)
        end
    end
    ret aws.ForAws("eu-central-1", bucket)
end

func main:
    each provider in ["aws", "r2", "spaces", "minio"]:
        cfg := storage(provider, "media")
        println provider, cfg.endpoint, cfg.region, cfg.path_style
    end
end
Output
aws https://s3.eu-central-1.amazonaws.com eu-central-1 false
r2 https://0123456789abcdef.r2.cloudflarestorage.com auto true
spaces https://ams3.digitaloceanspaces.com ams3 false
minio http://127.0.0.1:9000 us-east-1 true

None of these calls touch the network, so the output above is exact. Add the keys with WithCredentials, or start from FromEnvironment, which reads AWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY, AWS_REGION and AWS_ENDPOINT_URL.

Trying it locally with MinIO

MinIO runs an S3 compatible server on your own machine, which is the cheapest way to develop and test. Start it with Docker:

docker run -p 9000:9000 -p 9001:9001 minio/minio server /data --console-address :9001

The default keys are minioadmin and minioadmin. The program creates the bucket if it is missing, writes two objects under a date prefix, lists that prefix and reads one object back. Keys are just names: the slashes only look like folders, and listing by prefix is how you walk them.

aws-guide-minio.salam
import aws

func main:
    mut cfg := aws.ForMinio("http://127.0.0.1:9000", "backups")
    cfg = aws.WithCredentials(cfg, "minioadmin", "minioadmin")
    if not aws.S3BucketExists(cfg, "backups"):
        made := aws.S3CreateBucket(cfg, "backups")
        if not made.ok:
            println "could not create the bucket:", made.status, made.code, made.error
            ret 1
        end
    end
    _ := aws.S3Put(cfg, "2026/10/notes.txt", "first backup", "text/plain")
    _ := aws.S3Put(cfg, "2026/10/todo.txt", "buy milk", "text/plain")
    mut listing := aws.S3ListPrefix(cfg, "2026/10/")
    each item in listing.items:
        println item.key, item.size
    end
    aws.ListFree(listing)
    got := aws.S3Get(cfg, "2026/10/notes.txt")
    if got.ok:
        println "read back:", got.body
    else:
        println "read failed:", got.status, got.code
    end
end

Each call returns a Result. When ok is false, status is the HTTP status and code is S3's own error code, such as NoSuchKey or AccessDenied; branch on code, not on the message text. A list holds memory of its own, so free it with ListFree when you are done.

Large files and binary data

S3UploadFile reads a file from disk and picks the method by size. Up to the part size (8 MB by default, set part_size in PutOptions, never less than 5 MB) it sends one PUT; above that it streams the file in parts with a multipart upload, so memory use stays at one part. S3DownloadFile fetches the object in 8 MB ranges into name.part and renames it only when the whole file has arrived, so a failed download never leaves a half-written file under the real name.

aws-guide-files.salam
import aws

func main:
    mut cfg := aws.ForMinio("http://127.0.0.1:9000", "backups")
    cfg = aws.WithCredentials(cfg, "minioadmin", "minioadmin")
    opts := aws.PutOptions { content_type = "application/gzip", storage_class = "STANDARD_IA" }
    up := aws.S3UploadFile(cfg, "db/2026-10-17.sql.gz", "/var/backups/shop.sql.gz", opts)
    if not up.ok:
        println "upload failed:", up.code, up.error
        ret 1
    end
    println "uploaded", up.bytes, "bytes in", up.parts, "part(s)"
    down := aws.S3DownloadFile(cfg, "db/2026-10-17.sql.gz", "/tmp/restore.sql.gz")
    if not down.ok:
        println "download failed:", down.code, down.error
        ret 1
    end
    println "restored", down.bytes, "bytes to", down.path
    mut logo := aws.S3GetBytes(cfg, "site/logo.png")
    if logo.ok:
        println "logo.png is", logo.len, "bytes"
    end
    aws.FreeBytes(logo)
end

TransferResult tells you how many bytes moved and in how many parts. storage_class, cache_control, sse and the other PutOptions fields become the matching S3 headers. For a whole directory there is S3UploadDir.

Letting the browser upload directly

A presigned URL lets a browser upload or download one object without ever seeing your keys, and without the file passing through your server. Your server signs the URL; the browser sends a plain PUT to it. When content_type is set, it becomes part of the signature and the upload must send exactly that type. response_content_disposition on a download makes the browser save the file under the name you choose.

aws-guide-presign.salam
import aws

func main:
    mut cfg := aws.ForAws("eu-central-1", "user-uploads")
    cfg = aws.WithCredentials(
        cfg, "AKIAIOSFODNN7EXAMPLE", "wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY"
    )
    at := 1792224000 as i64
    upload := aws.PresignOptions { expires = 300, content_type = "image/jpeg" }
    put_url := aws.S3PresignWith(cfg, "PUT", "avatars/42.jpg", upload, at)
    println "upload:", put_url.Len() > 0
    println put_url.Substr(0, put_url.Find("?"))
    println "expires in 300s:", put_url.Find("X-Amz-Expires=300") >= 0
    println "content type is signed:", put_url.Find("content-type") >= 0
    download := aws.PresignOptions {
        expires = 3600, response_content_disposition = "attachment; filename=\"photo.jpg\""
    }
    get_url := aws.S3PresignWith(cfg, "GET", "avatars/42.jpg", download, at)
    println "download asks to save:", get_url.Find("response-content-disposition=attachment") >= 0
    println "same signature twice:",
        get_url == aws.S3PresignWith(cfg, "GET", "avatars/42.jpg", download, at)
end
Output
upload: true
https://user-uploads.s3.eu-central-1.amazonaws.com/avatars/42.jpg
expires in 300s: true
content type is signed: true
download asks to save: true
same signature twice: true

Signing is a local computation, so this program runs without a network. It uses S3PresignWith with a fixed time to get the same URL on every run; in a real program use S3PresignPut or S3PresignGet, which sign with the current time. Keep expires short: anyone who has the URL can use it until then.

A queue worker with SQS

SQS holds jobs until a worker takes them. SqsReceive waits up to wait_seconds for messages, which costs far less than asking again and again. A received message is hidden from other workers, not removed: delete it with its receipt once the work is done, or release it with SqsRelease so another worker can try at once. A message that is neither comes back by itself when its visibility timeout ends.

aws-guide-worker.salam
import aws

func handle(body: str): bool:
    println "resizing", body
    ret body.Len() > 0
end

func main:
    cfg := aws.FromEnvironment("")
    if cfg.access_key.Len() == 0 or cfg.secret_key.Len() == 0:
        println "set AWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY and AWS_REGION"
        ret 1
    end
    queue := aws.SqsQueueUrl(cfg, "image-jobs")
    if queue.Len() == 0:
        println "the queue image-jobs does not exist"
        ret 1
    end
    _ := aws.SqsSend(cfg, queue, "photos/beach.jpg")
    opts := aws.ReceiveOptions { max_messages = 10, wait_seconds = 20 }
    batch := aws.SqsReceive(cfg, queue, opts)
    if not batch.ok:
        println "receive failed:", batch.code, batch.error
        ret 1
    end
    each m in batch.items:
        if handle(m.body):
            _ := aws.SqsDelete(cfg, queue, m.receipt)
        else:
            _ := aws.SqsRelease(cfg, queue, m.receipt)
        end
    end
    println "handled", batch.items.Len(), "message(s)"
end

The program checks the keys itself instead of calling Configured, because a queue worker has no bucket. Run it with real AWS credentials and an existing queue named image-jobs. In a real worker, put the receive in a loop and make each job safe to run twice, because SQS delivers every message at least once.

Calling any other AWS API

Most AWS services take a signed POST with a JSON body and an X-Amz-Target header that names the operation. NewJsonCall builds such a call (NewJson11Call for services that want JSON 1.1, NewQueryCall for the older form APIs, NewRestCall for REST ones), and Invoke signs and sends it. The endpoint comes from the service name and the region. This program looks up one DynamoDB item. PreparedCall shows the exact request Invoke would send, signed at a fixed time, without touching the network:

aws-guide-dynamodb.salam
import aws

func main:
    mut cfg := aws.Config { region = "eu-west-1" }
    cfg = aws.WithCredentials(cfg, "AKIDEXAMPLE", "wJalrXUtnFEMI/K7MDENG+bPxRfiCYEXAMPLEKEY")
    item := `{"TableName": "orders", "Key": {"order_id": {"S": "A-1042"}}}`
    mut call := aws.NewJsonCall("dynamodb", "DynamoDB_20120810.GetItem", item)
    println aws.PreparedCall(cfg, call, 1760000000 as i64)
    aws.CallFree(call)
end
Output
POST / HTTP/1.1
Host: dynamodb.eu-west-1.amazonaws.com
Content-Type: application/x-amz-json-1.0
X-Amz-Target: DynamoDB_20120810.GetItem
x-amz-content-sha256: 4121fbc59183f2c71317b22f5a5e996b56f755df4905a3006519db21410ef47c
x-amz-date: 20251009T085320Z
Authorization: AWS4-HMAC-SHA256 Credential=AKIDEXAMPLE/20251009/eu-west-1/dynamodb/aws4_request, SignedHeaders=content-type;host;x-amz-content-sha256;x-amz-date;x-amz-target, Signature=f8e075bd147ac5d5f44a7c371cb66fd2cb421d5156ec10bde939b751b6c9a011
Content-Length: 61
Connection: close

{"TableName": "orders", "Key": {"order_id": {"S": "A-1042"}}}

With real keys, res := aws.Invoke(cfg, call) sends it; res.body is the JSON answer and, on failure, res.code is the AWS error type such as ResourceNotFoundException. The JSON format of each operation is in the AWS API reference of that service.

Which function for which job

JobFunctions
Choose the providerForAws, ForMinio, ForR2, ForSpaces, ForEndpoint, FromEnvironment
Write and read small objectsS3Put, S3Get, S3Stat, S3Delete
Files of any sizeS3UploadFile, S3DownloadFile (multipart when needed)
Walk a folderS3ListPrefix, S3ListAll, S3Keys
Browser uploads and downloadsS3PresignPut, S3PresignGet, S3PresignPost
Background jobsSqsSend, SqsReceive, SqsDelete
Temporary credentialsAssumeRole, then Apply
Any other AWS APINewJsonCall and Invoke

Types

ObjectEntry

#
struct ObjectEntry

One object in a listing.

NameTypeDescription
keystr = ""The key.
sizei64 = 0The size.
etagstr = ""The ETag.
last_modifiedstr = ""When it changed.
modified_epochi64 = 0The same in Unix seconds.
storage_classstr = ""The class.
ownerstr = ""The owner.
version_idstr = ""The version.
is_latestbool = falseIt is the latest version.
delete_markerbool = falseIt is a delete marker.
aws-Parse.salam
import aws

func main:
    mut cfg := aws.ForAws("eu-west-1", "")
    cfg = aws.WithCredentials(
        cfg, "AKIAIOSFODNN7EXAMPLE", "wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY"
    )
    at := 1369353600 as i64

    listing := `<ListBucketResult><Name>photos</Name><Prefix>2026/</Prefix><KeyCount>2</KeyCount><IsTruncated>true</IsTruncated><NextContinuationToken>tok2</NextContinuationToken>
<Contents><Key>2026/a.jpg</Key><Size>1200</Size><ETag>"aa11"</ETag><LastModified>2026-03-20T10:00:00.000Z</LastModified><StorageClass>STANDARD</StorageClass></Contents>
<Contents><Key>2026/b.jpg</Key><Size>800</Size><ETag>"bb22"</ETag><LastModified>2026-03-21T10:00:00.000Z</LastModified><StorageClass>STANDARD</StorageClass></Contents>
<CommonPrefixes><Prefix>2026/thumbs/</Prefix></CommonPrefixes></ListBucketResult>`
    mut list := aws.ParseListing(listing, 200)
    println list.ok,
        list.name,
        list.truncated,
        list.next_token,
        aws.ListCount(list),
        aws.ListTotalSize(list)
    entry := aws.ListAt(list, 0)
    println entry.key, entry.size, entry.etag, entry.last_modified, entry.storage_class
    println aws.ListPrefixCount(list), aws.ListPrefixAt(list, 0)
    println aws.ListToResult(list).ok
    aws.ListFree(list)

    mut keys := aws.NewKeyList()
    aws.KeyPush(keys, "tmp/1")
    aws.KeyPush(keys, "tmp/2")
    println aws.KeyCount(keys), aws.KeyAt(keys, 1)
    aws.KeyFree(keys)
    println aws.S3ExpiryRule("logs/", 30, 7)

    queue := "https://sqs.eu-west-1.amazonaws.com/123456789012/jobs"
    reply := "<ReceiveMessageResponse><ReceiveMessageResult><Message><MessageId>m-1</MessageId><ReceiptHandle>AQEB==</ReceiptHandle><MD5OfBody>fafb</MD5OfBody><Body>invoice 42</Body><Attribute><Name>ApproximateReceiveCount</Name><Value>2</Value></Attribute><MessageAttribute><Name>tenant</Name><Value><DataType>String</DataType><StringValue>acme</StringValue></Value></MessageAttribute></Message></ReceiveMessageResult></ReceiveMessageResponse>"
    mut messages := aws.ParseReceive(reply, 200)
    println messages.ok, aws.MessageCount(messages)
    msg := aws.MessageAt(messages, 0)
    println msg.id, msg.body, msg.receipt, msg.receive_count, aws.MessageAttribute(msg, "tenant")
    aws.MessageListFree(messages)

    mut out := aws.OutMessage {
        body = "job",
        delay = 30,
        group_id = "g1",
        dedup_id = "d1"
    }
    aws.HeaderSet(out.attributes, "tenant", "acme")
    mut send := aws.SqsSendCall(queue, out)
    println aws.CallBodyText(send)
    aws.CallFree(send)
    mut receive := aws.SqsReceiveCall(
        queue, aws.ReceiveOptions { max_messages = 99, wait_seconds = 60 }
    )
    println aws.CallBodyText(receive)
    aws.CallFree(receive)
    println aws.SQS_VERSION, aws.SQS_MAX_MESSAGES, aws.SQS_MAX_WAIT, aws.SQS_MAX_BATCH
    println aws.SqsRedrivePolicy("arn:aws:sqs:eu-west-1:123456789012:dead", 5)

    mut call := aws.NewQueryCall("sts", "GetCallerIdentity", aws.STS_VERSION)
    aws.CallParam(call, "Name", "ali")
    aws.CallParamInt(call, "DurationSeconds", 900)
    println aws.CallBodyText(call)
    head := aws.PreparedCall(cfg, call, at)
    println head.Find("POST / HTTP/1.1") == 0, head.Find("Host: sts.eu-west-1.amazonaws.com") >= 0
    aws.CallFree(call)

    mut dynamo := aws.NewJsonCall("dynamodb", "DynamoDB_20120810.ListTables", "{}")
    aws.CallRegion(dynamo, "eu-central-1")
    aws.CallHeader(dynamo, "x-amz-meta-app", "salam")
    println aws.PreparedCall(cfg, dynamo, at).Find(
        "X-Amz-Target: DynamoDB_20120810.ListTables"
    ) >= 0
    logs := aws.NewJson11Call("logs", "Logs_20140328.DescribeLogGroups", "{}")
    println logs.content_type

    mut rest := aws.NewRestCall("lambda", "GET", "/2015-03-31/functions")
    aws.CallQuery(rest, "MaxItems", "5")
    aws.CallBody(rest, "", "application/json")
    aws.CallEndpoint(rest, "http://127.0.0.1:4566")
    println aws.PreparedCall(cfg, rest, at).Find(
        "GET /2015-03-31/functions?MaxItems=5 HTTP/1.1"
    ) == 0

    failure := `{"__type":"com.amazon#ResourceNotFoundException","message":"Table not found"}`
    println aws.ServiceErrorCode(failure), aws.ServiceErrorMessage(failure, 400)
end
Output
true photos true tok2 2 2000
2026/a.jpg 1200 aa11 2026-03-20T10:00:00.000Z STANDARD
1 2026/thumbs/
true
2 tmp/2
<LifecycleConfiguration><Rule><ID>salam-expiry</ID><Filter><Prefix>logs/</Prefix></Filter><Status>Enabled</Status><Expiration><Days>30</Days></Expiration><AbortIncompleteMultipartUpload><DaysAfterInitiation>7</DaysAfterInitiation></AbortIncompleteMultipartUpload></Rule></LifecycleConfiguration>
true 1
m-1 invoice 42 AQEB== 2 acme
Action=SendMessage&Version=2012-11-05&MessageBody=job&DelaySeconds=30&MessageGroupId=g1&MessageDeduplicationId=d1&MessageAttribute.1.Name=tenant&MessageAttribute.1.Value.DataType=String&MessageAttribute.1.Value.StringValue=acme
Action=ReceiveMessage&Version=2012-11-05&MaxNumberOfMessages=10&WaitTimeSeconds=20&AttributeName.1=All&MessageAttributeName.1=All
2012-11-05 10 20 10
{"deadLetterTargetArn":"arn:aws:sqs:eu-west-1:123456789012:dead","maxReceiveCount":"5"}
Action=GetCallerIdentity&Version=2011-06-15&Name=ali&DurationSeconds=900
true true
true
application/x-amz-json-1.1
true
ResourceNotFoundException Table not found

ObjectList

#
struct ObjectList

A list of objects.

NameTypeDescription
okbool = falseIt succeeded.
statusint = 0The HTTP status code.
itemsVector<ObjectEntry>The objects.
prefixesVector<str>The common prefixes, that is, the "folders".
truncatedbool = falseThere is another page.
next_tokenstr = ""The token of the next page.
next_key_markerstr = ""The key of the next page in a version listing.
next_version_markerstr = ""The version of the next page.
key_countint = 0The number of keys.
namestr = ""The bucket name.
prefixstr = ""The prefix.
delimiterstr = ""The delimiter.
errorstr = ""The error message.
codestr = ""The service error code, such as NoSuchKey.

The example for this item is shown with the ones above: aws-Parse.salam

BucketEntry

#
struct BucketEntry

One bucket.

NameTypeDescription
namestr = ""The name.
createdstr = ""When it was created.
created_epochi64 = 0The same in Unix seconds.
regionstr = ""The region.
aws-Buckets.salam
import aws

func main:
    cfg := aws.FromEnvironment("")
    if not aws.Configured(cfg):
        println "AWS credentials are not set"
        ret
    end

    bucket := "salam-demo-2026"
    _ := aws.S3CreateBucket(cfg, bucket)
    _ := aws.S3CreateBucketAcl(cfg, bucket + "-logs", "private")
    println aws.S3BucketExists(cfg, bucket),
        aws.S3HeadBucket(cfg, bucket).status,
        aws.S3BucketRegion(cfg, bucket)

    mut list := aws.S3ListBuckets(cfg)
    println list.ok, list.owner, aws.BucketCount(list)
    repeat aws.BucketCount(list) in i:
        b := aws.BucketAt(list, i)
        println b.name, b.created, b.region
    end
    aws.BucketListFree(list)

    _ := aws.S3SetVersioning(cfg, bucket, true)
    println aws.S3Versioning(cfg, bucket)
    mut tags := aws.NewTags()
    aws.TagSet(tags, "project", "salam")
    _ := aws.S3SetBucketTags(cfg, bucket, tags)
    aws.HeaderFree(tags)
    mut current := aws.S3BucketTags(cfg, bucket)
    println aws.HeaderGet(current, "project")
    aws.HeaderFree(current)
    _ := aws.S3DeleteBucketTags(cfg, bucket)

    policy := `{"Version":"2012-10-17","Statement":[{"Effect":"Allow","Principal":"*","Action":"s3:GetObject","Resource":"arn:aws:s3:::salam-demo-2026/public/*"}]}`
    _ := aws.S3SetBucketPolicy(cfg, bucket, policy)
    println aws.S3BucketPolicy(cfg, bucket).Len() > 0
    _ := aws.S3DeleteBucketPolicy(cfg, bucket)
    _ := aws.S3SetBucketCors(cfg, bucket, "https://salamlang.ir", "GET,PUT", 3600)
    println aws.S3BucketCors(cfg, bucket).Len() > 0
    _ := aws.S3DeleteBucketCors(cfg, bucket)
    _ := aws.S3SetLifecycle(cfg, bucket, aws.S3ExpiryRule("tmp/", 7, 1))
    println aws.S3Lifecycle(cfg, bucket).Len() > 0
    _ := aws.S3DeleteLifecycle(cfg, bucket)

    _ := aws.S3DeleteBucket(cfg, bucket + "-logs")
    println aws.S3DeleteBucket(cfg, bucket).ok
end

BucketList

#
struct BucketList

A list of buckets.

NameTypeDescription
okbool = falseIt succeeded.
statusint = 0The HTTP status code.
itemsVector<BucketEntry>The buckets.
ownerstr = ""The owner.
errorstr = ""The error message.
codestr = ""The service error code, such as NoSuchKey.

The example for this item is shown with the ones above: aws-Buckets.salam

ListOptions

#
struct ListOptions

Listing options.

NameTypeDescription
prefixstr = ""The prefix.
delimiterstr = ""The delimiter, usually /.
max_keysint = 0The most keys on a page.
continuation_tokenstr = ""The token of the next page.
start_afterstr = ""Start after this key.
fetch_ownerbool = falseAsk for the owner too.
url_encodebool = trueThe keys come encoded.
aws-Objects.salam
import aws

func main:
    cfg := aws.FromEnvironment("photos")
    if not aws.Configured(cfg):
        println "set AWS_ACCESS_KEY_ID and AWS_SECRET_ACCESS_KEY"
        ret
    end

    put := aws.S3Put(cfg, "notes/hello.txt", "hello world", "text/plain; charset=utf-8")
    println put.ok, put.status, put.etag, put.request_id
    o := aws.PutOptions {
        content_type = "text/html",
        cache_control = "max-age=3600",
        storage_class = "STANDARD_IA",
        acl = "public-read"
    }
    aws.HeaderSet(o.meta, "owner", "ali")
    _ := aws.S3PutWith(cfg, "site/index.html", "<h1>hello</h1>", o)
    data := "salam"
    _ := aws.S3PutBytes(cfg, "raw.bin", data as void*, data.Len(), "application/octet-stream")
    _ := aws.S3PutBytesWith(cfg, "raw2.bin", data as void*, data.Len(), o)

    got := aws.S3Get(cfg, "notes/hello.txt")
    if got.ok:
        println got.body, got.length, aws.ResultHeader(got, "Content-Type")
    else:
        println got.status, got.code, got.error
    end
    _ := aws.S3GetWith(cfg, "notes/hello.txt", aws.GetOptions { if_none_match = got.etag })
    mut b := aws.S3GetBytes(cfg, "raw.bin")
    println b.ok, b.len, aws.BytesHeader(b, "ETag")
    aws.FreeBytes(b)
    mut b2 := aws.S3GetRange(cfg, "raw.bin", 0, 1)
    aws.FreeBytes(b2)
    mut b3 := aws.S3GetBytesWith(cfg, "raw.bin", aws.GetOptions { range_start = 2, range_end = 4 })
    aws.FreeBytes(b3)

    info := aws.S3Stat(cfg, "site/index.html")
    println info.ok, info.size, info.content_type, info.last_modified, info.storage_class
    _ := aws.S3StatVersion(cfg, "site/index.html", info.version_id)
    println aws.S3Head(cfg, "raw.bin").status,
        aws.S3Exists(cfg, "raw.bin"),
        aws.S3Size(cfg, "raw.bin")
    println aws.S3ObjectChecksum(cfg, "raw.bin")

    _ := aws.S3Copy(cfg, "notes/hello.txt", "notes/copy.txt")
    _ := aws.S3CopyWith(
        cfg, "notes/hello.txt", "archive/hello.txt", aws.CopyOptions { storage_class = "GLACIER" }
    )
    _ := aws.S3Move(cfg, "notes/copy.txt", "notes/moved.txt")
    _ := aws.S3Touch(cfg, "notes/moved.txt", aws.CopyOptions {})
    _ := aws.S3Restore(cfg, "archive/hello.txt", 2, "Standard")

    _ := aws.S3SetObjectTags(cfg, "raw.bin", aws.NewTags())
    _ := aws.S3AddObjectTag(cfg, "raw.bin", "team", "web")
    mut t := aws.S3ObjectTags(cfg, "raw.bin")
    println aws.TagString(t)
    aws.HeaderFree(t)
    mut t2 := aws.S3ObjectTagsVersion(cfg, "raw.bin", "")
    aws.HeaderFree(t2)
    _ := aws.S3DeleteObjectTags(cfg, "raw.bin")
    _ := aws.S3MakePublic(cfg, "raw.bin")
    _ := aws.S3MakePrivate(cfg, "raw.bin")
    _ := aws.S3SetObjectAcl(cfg, "raw.bin", "private")
    println aws.S3ObjectAcl(cfg, "raw.bin").Len() > 0
    _ := aws.S3SetLegalHold(cfg, "raw.bin", true)
    println aws.S3LegalHold(cfg, "raw.bin")
    _ := aws.S3SetRetention(cfg, "raw.bin", "GOVERNANCE", 1893456000 as i64)

    mut l := aws.S3List(cfg, aws.ListOptions { prefix = "notes/", max_keys = 100 })
    each e in l.items:
        println e.key, e.size
    end
    aws.ListFree(l)
    mut l2 := aws.S3ListPrefix(cfg, "site/")
    aws.ListFree(l2)
    mut l3 := aws.S3ListFolder(cfg, "")
    println aws.ListPrefixCount(l3)
    aws.ListFree(l3)
    mut l4 := aws.S3ListAll(cfg, "")
    println aws.ListCount(l4), aws.ListTotalSize(l4)
    aws.ListFree(l4)
    mut l5 := aws.S3ListAllWith(cfg, aws.ListOptions { prefix = "site/" })
    aws.ListFree(l5)
    mut l6 := aws.S3ListV1(cfg, aws.ListOptions {}, "")
    aws.ListFree(l6)
    mut l7 := aws.S3ListVersions(cfg, aws.ListOptions { prefix = "raw" }, "", "")
    aws.ListFree(l7)
    mut keys := aws.S3Keys(cfg, "notes/")
    _ := aws.S3DeleteMany(cfg, keys)
    aws.KeyFree(keys)
    _ := aws.S3DeletePrefix(cfg, "site/")
    _ := aws.S3DeleteVersion(cfg, "raw2.bin", "")
    println aws.S3Delete(cfg, "raw.bin").ok
end

KeyList

#
struct KeyList

A list of keys.

NameTypeDescription
itemsVector<str>The keys.

The example for this item is shown with the ones above: aws-Parse.salam

Call

#
struct Call

A call to any other AWS service, such as DynamoDB or Lambda.

NameTypeDescription
servicestr = ""The service name.
regionstr = ""The region; empty means the region of the configuration.
methodstr = "POST"The HTTP method.
pathstr = "/"The path.
targetstr = ""The X-Amz-Target header for the JSON APIs.
content_typestr = ""The content type.
queryHeadersThe query string parameters.
headersHeadersThe headers.
paramsHeadersThe form parameters for the query APIs.
bodystr = ""The body.
endpointstr = ""A custom address, such as LocalStack.
global_endpointbool = falseThe service is global, such as IAM.

The example for this item is shown with the ones above: aws-Parse.salam

PartRef

#
struct PartRef

One uploaded part.

NameTypeDescription
numberint = 0The number, from 1.
etagstr = ""The ETag of the part.
sizei64 = 0The size.
aws-Files.salam
import aws

func main:
    cfg := aws.FromProfile("default", "backup")
    if not aws.Configured(cfg):
        println "the default profile was not found in ~/.aws"
        ret
    end

    o := aws.PutOptions { part_size = aws.S3_PART_DEFAULT }
    up := aws.S3UploadFile(cfg, "db/dump.sql", "/tmp/dump_en.sql", o)
    println up.ok, up.bytes, up.parts, up.etag
    println aws.S3FileEtag("/tmp/dump_en.sql", aws.S3_PART_DEFAULT) == up.etag
    _ := aws.S3UploadFileAs(cfg, "img/logo.png", "/tmp/logo_en.png", "image/png")
    down := aws.S3DownloadFile(cfg, "db/dump.sql", "/tmp/restore_en.sql")
    println down.ok, down.path, down.error

    dir := aws.S3UploadDir(cfg, "/var/www/site", "site/", aws.PutOptions {})
    println dir.ok, dir.files, dir.bytes, dir.skipped, dir.failed_path
    _ := aws.S3DownloadPrefix(cfg, "site/", "/tmp/site_en")

    println aws.S3_PART_MIN, aws.S3_PART_MAX_COUNT
    mut upload := aws.S3CreateUpload(
        cfg, "video.mp4", aws.PutOptions { content_type = "video/mp4" }
    )
    if not upload.ok:
        println upload.error
        ret
    end
    chunk := "x" * aws.S3_PART_MIN
    _ := aws.S3UploadPart(cfg, upload, 1, chunk as void*, chunk.Len())
    _ := aws.S3UploadPartCopy(cfg, upload, 2, "old.mp4", aws.CopyOptions {}, 0, 5242879)
    println aws.UploadParts(upload), aws.UploadBytes(upload)
    parts := aws.S3ListParts(cfg, "video.mp4", upload.upload_id)
    repeat aws.PartCount(parts) in i:
        p := aws.PartAt(parts, i)
        println p.number, p.etag, p.size
    end
    println aws.S3CompleteUpload(cfg, upload).ok
    aws.UploadFreeParts(upload)

    pending := aws.S3ListUploads(cfg, "")
    repeat aws.UploadCount(pending) in j:
        u := aws.UploadAt(pending, j)
        _ := aws.S3AbortUpload(cfg, aws.Upload { key = u.key, upload_id = u.upload_id })
    end
    _ := aws.S3PutLarge(cfg, "big.bin", chunk as void*, chunk.Len(), 0, aws.PutOptions {})
    _ := aws.S3CopyLarge(cfg, "big.bin", "big2.bin", 0, aws.CopyOptions {})
end

Upload

#
struct Upload

One multipart upload.

NameTypeDescription
okbool = falseIt succeeded.
statusint = 0The HTTP status code.
upload_idstr = ""The upload id.
keystr = ""The key.
bucketstr = ""The bucket.
partsVector<PartRef>The uploaded parts.
errorstr = ""The error message.
codestr = ""The service error code, such as NoSuchKey.

The example for this item is shown with the ones above: aws-Files.salam

PartList

#
struct PartList

A list of parts.

NameTypeDescription
okbool = falseIt succeeded.
statusint = 0The HTTP status code.
itemsVector<PartRef>The parts.
truncatedbool = falseThere are more parts.
next_markerstr = ""Where the next page starts.
errorstr = ""The error message.
codestr = ""The service error code, such as NoSuchKey.

The example for this item is shown with the ones above: aws-Files.salam

UploadRef

#
struct UploadRef

One unfinished upload.

NameTypeDescription
keystr = ""The key.
upload_idstr = ""The id.
initiatedstr = ""When it started.
initiated_epochi64 = 0When it started, in Unix seconds.
storage_classstr = ""The storage class.

The example for this item is shown with the ones above: aws-Files.salam

UploadList

#
struct UploadList

A list of unfinished uploads.

NameTypeDescription
okbool = falseIt succeeded.
statusint = 0The HTTP status code.
itemsVector<UploadRef>The uploads.
truncatedbool = falseThere are more.
next_key_markerstr = ""The key of the next page.
next_upload_markerstr = ""The id of the next page.
errorstr = ""The error message.
codestr = ""The service error code, such as NoSuchKey.

The example for this item is shown with the ones above: aws-Files.salam

TransferResult

#
struct TransferResult

The result of transferring one file.

NameTypeDescription
okbool = falseIt succeeded.
statusint = 0The HTTP status code.
bytesi64 = 0The bytes transferred.
partsint = 0The number of parts; 1 for a small file.
etagstr = ""The ETag.
pathstr = ""The file path.
keystr = ""The key.
errorstr = ""The error message.
codestr = ""The service error code, such as NoSuchKey.

The example for this item is shown with the ones above: aws-Files.salam

DirResult

#
struct DirResult

The result of transferring a folder.

NameTypeDescription
okbool = falseEverything was transferred.
filesint = 0The number of files.
bytesi64 = 0The total bytes.
skippedint = 0The files that were skipped.
failed_pathstr = ""The first file that failed.
errorstr = ""The error message.
codestr = ""The service error code, such as NoSuchKey.

The example for this item is shown with the ones above: aws-Files.salam

Config

#
struct Config

The connection configuration: address, region, bucket and credentials.

NameTypeDescription
endpointstr = ""The service address.
regionstr = "us-east-1"The region; us-east-1 by default.
bucketstr = ""The default bucket.
access_keystr = ""The access key id.
secret_keystr = ""The secret key.
session_tokenstr = ""The session token.
path_stylebool = truePath addressing, host/bucket/key, instead of bucket.host/key.
servicestr = "s3"The service name in the signature.
expiresint = 900The default expiry of presigned URLs, in seconds.
retryint = 3The number of attempts in all, from 1 to 10; network errors, 429 and 5xx answers are tried again.
retry_base_msint = 100The base delay between attempts.
anonymousbool = falseUnsigned, for public buckets.
request_payerbool = falseThe requester pays for the request.
timeout_msint = 0The timeout of each request, in milliseconds.
aws-Config.salam
import aws

func main:
    println aws.AwsEndpoint("eu-central-1"),
        aws.StsEndpoint("eu-central-1"),
        aws.ServiceEndpoint("sqs", "eu-west-1")
    println aws.ForAws("eu-central-1", "photos").endpoint,
        aws.ForMinio("http://127.0.0.1:9000/", "photos").endpoint
    println aws.ForR2("acct", "photos").endpoint, aws.ForSpaces("ams3", "photos").endpoint
    println aws.ForWasabi("eu-central-1", "photos").endpoint,
        aws.ForBackblaze("us-west-004", "photos").endpoint
    println aws.ForEndpoint("https://s3.example.ir", "ir-tehran", "photos").region

    mut cfg := aws.NewConfig("http://127.0.0.1:9000", "photos")
    println aws.Configured(cfg)
    cfg = aws.WithCredentials(cfg, "AKIDEXAMPLE", "secret")
    cfg = aws.WithBucket(cfg, "backup")
    cfg = aws.WithSessionToken(cfg, "token")
    cfg = aws.WithRetry(cfg, 5, 200)
    println aws.Configured(cfg),
        cfg.bucket,
        cfg.retry,
        cfg.retry_base_ms,
        cfg.path_style,
        cfg.service
    println aws.Describe(cfg)

    text := "[default]\nregion = eu-west-1\n\n[profile work]\nregion = me-central-1\n"
    println aws.ParseIni(text, "default", "region"), aws.ParseIni(text, "profile work", "region")
    println aws.CredentialsPath().Len() > 0, aws.ConfigPath().Len() > 0
    println aws.FromEnvironment("photos").bucket

    creds := aws.StaticCredentials("AKIDEXAMPLE", "secret")
    println creds.ok, creds.source, aws.ExpiredNow(creds), aws.SOURCE_CONTAINER
    applied := aws.Apply(aws.ForAws("", "photos"), creds)
    println applied.access_key

    body := `<AssumeRoleResponse><AssumeRoleResult><Credentials><AccessKeyId>ASIAEXAMPLE</AccessKeyId><SecretAccessKey>s</SecretAccessKey><SessionToken>t</SessionToken><Expiration>2030-01-01T00:00:00Z</Expiration></Credentials></AssumeRoleResult></AssumeRoleResponse>`
    temp := aws.ParseCredentials(body, 200, "sts")
    println temp.ok, temp.access_key, temp.session_token, temp.expires, temp.source
    now := 1893455000 as i64
    println aws.Expired(temp, now, aws.STS_DEFAULT_SKEW), aws.SecondsRemaining(temp, now)
    println aws.DescribeCredentials(temp)
    println aws.SOURCE_ENV, aws.SOURCE_PROFILE, aws.SOURCE_WEB_IDENTITY, aws.SOURCE_INSTANCE
    println aws.STS_VERSION, aws.STS_MIN_DURATION, aws.STS_MAX_DURATION

    chain := aws.DefaultChain()
    println chain.use_env, chain.use_profile, chain.use_instance, aws.ContainerChain().use_instance

    failed := aws.Failure("no network")
    println failed.ok, failed.error
end
Output
https://s3.eu-central-1.amazonaws.com https://sts.eu-central-1.amazonaws.com https://sqs.eu-west-1.amazonaws.com
https://s3.eu-central-1.amazonaws.com http://127.0.0.1:9000
https://acct.r2.cloudflarestorage.com https://ams3.digitaloceanspaces.com
https://s3.eu-central-1.wasabisys.com https://s3.us-west-004.backblazeb2.com
ir-tehran
false
true backup 5 200 true s3
endpoint=http://127.0.0.1:9000 bucket=backup region=us-east-1 addressing=path access_key=AKID... secret=set (6 chars)
eu-west-1 me-central-1
true true
photos
true static false container
AKIDEXAMPLE
true ASIAEXAMPLE t 2030-01-01T00:00:00Z sts
false 1000
temporary ASIA..., expires 2030-01-01T00:00:00Z, from sts
environment profile web-identity instance
2011-06-15 900 43200
true true false true
false no network

Result

#
struct Result

The result of one request.

NameTypeDescription
okbool = falseThe status code was 2xx.
statusint = 0The HTTP status code.
bodystr = ""The response body.
etagstr = ""The ETag without quotes.
lengthi64 = 0The body length.
errorstr = ""The error message.
headstr = ""The raw response headers.
codestr = ""The service error code, such as NoSuchKey.
request_idstr = ""The request id for AWS support.
version_idstr = ""The object version id.
aws-Sign.salam
import aws

func example(): aws.Config:
    ret aws.Config {
        endpoint = "https://s3.amazonaws.com",
        bucket = "examplebucket",
        access_key = "AKIAIOSFODNN7EXAMPLE",
        secret_key = "wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY",
        path_style = false
    }
end

func main:
    at := 1369353600 as i64
    date := aws.AmzDate(at)
    println date, aws.DateStamp(date), aws.Scope(aws.DateStamp(date), "us-east-1", aws.SERVICE_S3)
    println aws.EncodeKey("photos/a b+c.png"),
        aws.UriEncode("a b/c", true),
        aws.UriEncode("a b/c", false)
    println aws.ALGORITHM, aws.UNSIGNED_PAYLOAD
    println aws.EMPTY_SHA256 == aws.Sha256Bytes(null, 0)

    headers := "host:examplebucket.s3.amazonaws.com\nrange:bytes=0-9\nx-amz-content-sha256:" +
        aws.EMPTY_SHA256 + "\nx-amz-date:" + date + "\n"
    signed := aws.SignRequest(
        example(),
        "GET",
        "/test.txt",
        "",
        headers,
        "host;range;x-amz-content-sha256;x-amz-date",
        aws.EMPTY_SHA256,
        at
    )
    println signed.ok, signed.amz_date
    println signed.authorization
    println aws.SignString(example(), aws.DateStamp(date), "text").Len()
    println aws.SignQuery(
        example(), "GET", "/test.txt", "", "examplebucket.s3.amazonaws.com", at
    ).Len() > 0
    println aws.SignQueryHeaders(
        example(), "GET", "/test.txt", "", "host:examplebucket.s3.amazonaws.com\n", "host", at
    ).Len() > 0

    mut req := aws.NewRequest("GET", "test.txt")
    aws.SetHeader(req, "Range", "bytes=0-9")
    aws.SetQuery(req, "versionId", "v1")
    aws.SetQueryInt(req, "partNumber", 2)
    aws.SetFlag(req, "acl")
    print aws.CanonicalRequest(example(), req, at)
    println ""
    mut put := aws.NewRequest("PUT", "notes/a.txt")
    aws.SetText(put, "hello")
    head := aws.PreparedHead(example(), put, at)
    println head.Find("PUT /notes/a.txt HTTP/1.1") == 0, head.Find("Content-Length: 5") >= 0
    mut big := aws.NewRequest("PUT", "big.bin")
    aws.SetUnsignedPayload(big)
    println big.body_hash
    other := aws.NewBucketRequest("GET", "other", "")
    println other.bucket, aws.NewServiceRequest("GET").service_level

    text := "salam"
    aws.SetBody(big, text as void*, text.Len())
    println big.body_len
    println aws.S3ContentHash(text as void*, text.Len())
    println aws.S3ContentMd5(text as void*, text.Len()),
        aws.S3ChecksumSha256(text as void*, text.Len())
    println aws.S3ContentHashMd5(text as void*, text.Len()),
        aws.S3MultipartEtag(text as void*, text.Len(), 4)

    mut h := aws.NewHeaders()
    aws.HeaderSet(h, "Content-Type", "text/plain")
    aws.HeaderSet(h, "content-type", "text/html")
    aws.HeaderAdd(h, "x-amz-meta-tag", "a")
    aws.HeaderAdd(h, "x-amz-meta-tag", "b")
    println aws.HeaderCount(h), aws.HeaderGet(h, "CONTENT-TYPE"), aws.HeaderHas(h, "range")
    println aws.HeaderNameAt(h, 2), aws.HeaderValueAt(h, 2)
    aws.HeaderFree(h)

    mut tags := aws.NewTags()
    aws.TagSet(tags, "team", "web")
    aws.TagSet(tags, "env", "prod test")
    println aws.TagString(tags)

    println aws.Unquote("\"9b2cf5\"")
    err := "<Error><Code>NoSuchKey</Code><Message>The key does not exist</Message></Error>"
    println aws.ResultErrorCode(err), aws.ResultTag(err, "Message")
    println aws.ResultErrorMessage(err, 404)
    println aws.ResultErrorMessage("", 503)
end
Output
20130524T000000Z 20130524 20130524/us-east-1/s3/aws4_request
/photos/a%20b%2Bc.png a%20b/c a%20b%2Fc
AWS4-HMAC-SHA256 UNSIGNED-PAYLOAD
true
true 20130524T000000Z
AWS4-HMAC-SHA256 Credential=AKIAIOSFODNN7EXAMPLE/20130524/us-east-1/s3/aws4_request, SignedHeaders=host;range;x-amz-content-sha256;x-amz-date, Signature=f0e8bdb87c964420e857bd35b5d6ed310bd44f0170aba48dd91039c6036bdb41
64
true
true
GET
/test.txt
acl=&partNumber=2&versionId=v1
host:examplebucket.s3.amazonaws.com
range:bytes=0-9
x-amz-content-sha256:e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855
x-amz-date:20130524T000000Z

host;range;x-amz-content-sha256;x-amz-date
e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855
true true
UNSIGNED-PAYLOAD
other true
5
0582bd2c13fff71d7f40ef5586e3f4da05a3a61fe5ba9f0b4d06e99905ab83ea
3mg4JS+V07noA7KN8ztLqg== BYK9LBP/9x1/QO9VhuP02gWjph/lup8LTQbpmQWrg+o=
de6838252f95d3b9e803b28df33b4baa de6838252f95d3b9e803b28df33b4baa
3 text/html false
x-amz-meta-tag b
team=web&env=prod%20test
9b2cf5
NoSuchKey The key does not exist
The key does not exist
the object store answered 503

Signed

#
struct Signed

The result of signing.

NameTypeDescription
authorizationstr = ""The value of the Authorization header.
amz_datestr = ""The value of the x-amz-date header.
payload_hashstr = ""The body digest.
okbool = falseIt was signed; not without a secret key.

The example for this item is shown with the ones above: aws-Sign.salam

ChainOptions

#
struct ChainOptions

Options of the credential lookup chain; each source can be turned on or off.

NameTypeDescription
use_envbool = trueRead the environment variables.
use_profilebool = trueRead the profile.
profilestr = ""The profile name; empty means AWS_PROFILE or default.
use_web_identitybool = falseRead the web identity token.
use_containerbool = falseRead the container role.
use_instancebool = falseRead the EC2 instance role.
follow_rolesbool = trueAssume the roles a profile names with role_arn.
max_role_depthint = 4The longest chain of roles.
session_namestr = ""The session name for assuming a role.
durationint = 0How long the role is valid, in seconds.
timeout_msint = 1000The timeout for asking the container and the instance, in milliseconds.

The example for this item is shown with the ones above: aws-Config.salam

PresignOptions

#
struct PresignOptions

Options for a presigned URL.

NameTypeDescription
expiresint = 0How long it is valid, in seconds; seven days at most.
version_idstr = ""The version.
content_typestr = ""The content type the uploader must send.
aclstr = ""The ACL.
storage_classstr = ""The class.
response_content_typestr = ""The content type of the response.
response_content_dispositionstr = ""The Content-Disposition of the response; for the downloaded file name.
response_cache_controlstr = ""The Cache-Control of the response.
aws-Presign.salam
import aws

func main:
    mut cfg := aws.ForAws("", "examplebucket")
    cfg = aws.WithCredentials(
        cfg, "AKIAIOSFODNN7EXAMPLE", "wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY"
    )
    at := 1369353600 as i64
    println aws.S3Url(cfg, "cdn/42.png")
    println aws.S3PresignAt(cfg, "GET", "test.txt", 86400, at)

    o := aws.PresignOptions { expires = 600, content_type = "image/png" }
    url := aws.S3PresignWith(cfg, "PUT", "up.png", o, at)
    println url.Find("X-Amz-SignedHeaders=content-type%3Bhost") >= 0,
        url.Find("X-Amz-Expires=600") >= 0

    println aws.S3Presign(cfg, "DELETE", "old.txt", 60).Find("X-Amz-Expires=60&") >= 0
    println aws.S3PresignGet(cfg, "report.pdf", 3600).Find(
        "https://examplebucket.s3.amazonaws.com/report.pdf?"
    ) == 0
    println aws.S3PresignPut(cfg, "avatar.png", "image/png", 300).Find("content-type") >= 0
    println aws.S3PresignDownload(
        cfg, "r/123.pdf", "report.pdf", 300
    ).Find("response-content-disposition") >= 0

    po := aws.PostOptions {
        expires = 3600,
        key_is_prefix = true,
        content_type = "image/",
        content_type_is_prefix = true,
        max_bytes = 1048576 as i64,
        acl = "private"
    }
    form := aws.S3PresignPostAt(cfg, "incoming/", po, at)
    println form.ok, form.url
    println form.policy
    println aws.HeaderGet(form.fields, "x-amz-signature")
    println aws.PostFormHtml(form, "file").Find("<form") >= 0
    println aws.S3PresignPost(cfg, "a.png", aws.PostOptions {}).ok
end
Output
https://examplebucket.s3.amazonaws.com/cdn/42.png
https://examplebucket.s3.amazonaws.com/test.txt?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Credential=AKIAIOSFODNN7EXAMPLE%2F20130524%2Fus-east-1%2Fs3%2Faws4_request&X-Amz-Date=20130524T000000Z&X-Amz-Expires=86400&X-Amz-SignedHeaders=host&X-Amz-Signature=aeeed9bbccd4d02ee5c0109b86d86835f995330da4c265957d157751f604d404
true true
true
true
true
true
true https://examplebucket.s3.amazonaws.com
{"expiration":"2013-05-24T01:00:00Z","conditions":[{"bucket":"examplebucket"},["starts-with","$key","incoming/"],{"x-amz-algorithm":"AWS4-HMAC-SHA256"},{"x-amz-credential":"AKIAIOSFODNN7EXAMPLE/20130524/us-east-1/s3/aws4_request"},{"x-amz-date":"20130524T000000Z"},{"acl":"private"},["starts-with","$Content-Type","image/"],["content-length-range",0,1048576]]}
a4241c22845d07fcff1b88f34fa1dfaef4ef477c59a1ca388f9c346e609c01c9
true
true

PostOptions

#
struct PostOptions

Options for a browser upload form.

NameTypeDescription
expiresint = 0How long the policy is valid.
key_is_prefixbool = falseThe key is only a prefix and the browser decides the rest.
content_typestr = ""The content type.
content_type_is_prefixbool = falseThe content type is only a prefix, such as image/.
aclstr = ""The ACL.
cache_controlstr = ""The Cache-Control.
storage_classstr = ""The class.
min_bytesi64 = 0The smallest size.
max_bytesi64 = 0The largest size.
success_statusstr = ""The status code of a successful response.
success_redirectstr = ""The address to return to after the upload.
metaHeadersThe metadata.

The example for this item is shown with the ones above: aws-Presign.salam

PostForm

#
struct PostForm

A signed form.

NameTypeDescription
okbool = falseIt succeeded.
urlstr = ""The form action address.
fieldsHeadersThe hidden form fields.
policystr = ""The JSON policy before Base64.
errorstr = ""The error message.

The example for this item is shown with the ones above: aws-Presign.salam

Message

#
struct Message

A message received from a queue.

NameTypeDescription
idstr = ""The id.
bodystr = ""The text.
receiptstr = ""The receipt handle; for deleting it and changing its visibility.
md5str = ""The MD5 digest of the text.
receive_countint = 0How many times it was received.
sent_epochi64 = 0When it was sent, in Unix seconds.
group_idstr = ""The group in a FIFO queue.
dedup_idstr = ""The deduplication id.
attributesHeadersThe system attributes.
message_attributesHeadersThe sender attributes.

The example for this item is shown with the ones above: aws-Parse.salam

MessageList

#
struct MessageList

The received messages.

NameTypeDescription
okbool = falseIt succeeded.
statusint = 0The HTTP status code.
itemsVector<Message>The messages.
errorstr = ""The error message.
codestr = ""The service error code, such as NoSuchKey.

The example for this item is shown with the ones above: aws-Parse.salam

SendResult

#
struct SendResult

The result of sending.

NameTypeDescription
okbool = falseIt succeeded.
idstr = ""The message id.
md5str = ""The MD5 digest of the text.
sequencestr = ""The sequence number in a FIFO queue.
errorstr = ""The error message.
codestr = ""The service error code, such as NoSuchKey.
aws-Services.salam
import aws

func main:
    chain := aws.DefaultChain()
    creds := aws.Resolve(chain)
    if not creds.ok:
        println "no credentials were found:", creds.error
        ret
    end
    println aws.DescribeCredentials(creds)
    cfg := aws.ResolveConfig("photos", "eu-central-1", chain)
    println aws.FromEnvironmentCredentials().ok, aws.FromProfileCredentials("default", chain).ok
    println aws.FromWebIdentityCredentials(chain).ok, aws.FromContainerCredentials(1000).ok
    println aws.FromInstanceCredentials(1000).ok, aws.InstanceRegion(1000)

    who := aws.GetCallerIdentity(cfg)
    println who.ok, who.account, who.arn, who.user_id
    role := aws.AssumeRole(cfg, "arn:aws:iam::123456789012:role/deploy", "salam", 900)
    if role.ok:
        cfg2 := aws.Apply(cfg, role)
        println aws.Describe(cfg2)
    end
    _ := aws.AssumeRoleWith(
        cfg, "arn:aws:iam::123456789012:role/partner", "salam", 3600, "ext-42", ""
    )
    _ := aws.AssumeRoleWithWebIdentity(cfg, "arn:aws:iam::123456789012:role/ci", "ci", "token", 900)
    _ := aws.GetSessionToken(cfg, 3600, "arn:aws:iam::123456789012:mfa/ali", "123456")
    _ := aws.GetFederationToken(cfg, "guest", "", 900)

    created := aws.SqsCreateQueue(cfg, "jobs", aws.NewHeaders())
    queue := aws.SqsQueueUrl(cfg, "jobs")
    println created == queue, aws.SqsQueueArn(cfg, queue)
    mut queues := aws.SqsListQueues(cfg, "")
    repeat aws.QueueCount(queues) in i:
        println aws.QueueAt(queues, i)
    end
    aws.QueueListFree(queues)

    sent := aws.SqsSend(cfg, queue, "invoice 42")
    println sent.ok, sent.id, sent.md5, sent.sequence
    _ := aws.SqsSendWith(cfg, queue, aws.OutMessage { body = "later", delay = 60 })
    mut messages := aws.SqsReceive(
        cfg, queue, aws.ReceiveOptions { max_messages = 5, wait_seconds = 10 }
    )
    each msg in messages.items:
        println msg.body
        _ := aws.SqsDelete(cfg, queue, msg.receipt)
    end
    aws.MessageListFree(messages)
    mut batch := aws.SqsReceiveBatch(cfg, queue, 10)
    _ := aws.SqsDeleteBatch(cfg, queue, batch)
    aws.MessageListFree(batch)
    mut waiting := aws.SqsPoll(cfg, queue)
    if aws.MessageCount(waiting) > 0:
        receipt := aws.MessageAt(waiting, 0).receipt
        _ := aws.SqsChangeVisibility(cfg, queue, receipt, 120)
        _ := aws.SqsRelease(cfg, queue, receipt)
    end
    aws.MessageListFree(waiting)
    println aws.SqsDepth(cfg, queue)
    mut attrs := aws.NewHeaders()
    aws.HeaderSet(
        attrs,
        "RedrivePolicy",
        aws.SqsRedrivePolicy("arn:aws:sqs:eu-central-1:123456789012:dead", 5)
    )
    _ := aws.SqsSetAttributes(cfg, queue, attrs)
    aws.HeaderFree(attrs)
    mut current := aws.SqsAttributes(cfg, queue)
    println aws.HeaderGet(current, "VisibilityTimeout")
    aws.HeaderFree(current)
    _ := aws.SqsPurge(cfg, queue)
    _ := aws.SqsDeleteQueue(cfg, queue)

    mut call := aws.NewJsonCall("dynamodb", "DynamoDB_20120810.ListTables", "{}")
    result := aws.Invoke(cfg, call)
    println result.status, result.body
    aws.CallFree(call)

    req := aws.NewRequest("GET", "notes/hello.txt")
    println aws.Do(cfg, req).status
    mut raw := aws.DoBytes(cfg, req)
    aws.FreeBytes(raw)
end

OutMessage

#
struct OutMessage

A message to send.

NameTypeDescription
bodystr = ""The text.
delayint = 0The delay in seconds.
group_idstr = ""The group, for a FIFO queue.
dedup_idstr = ""The deduplication id.
attributesHeadersThe message attributes.

The example for this item is shown with the ones above: aws-Parse.salam

ReceiveOptions

#
struct ReceiveOptions

Options for receiving.

NameTypeDescription
max_messagesint = 1The most messages, 1 to 10.
wait_secondsint = 20The long poll, 0 to 20 seconds.
visibility_timeoutint = 0How long the received messages stay hidden.
want_attributesbool = trueAsk for the system attributes.
want_message_attributesbool = trueAsk for the message attributes.
receive_request_attempt_idstr = ""An id for safely repeating a receive in a FIFO queue.

The example for this item is shown with the ones above: aws-Parse.salam

QueueList

#
struct QueueList

A list of queues.

NameTypeDescription
okbool = falseIt succeeded.
itemsVector<str>The queue URLs.
errorstr = ""The error message.
codestr = ""The service error code, such as NoSuchKey.

The example for this item is shown with the ones above: aws-Services.salam

PutOptions

#
struct PutOptions

Options for writing an object.

NameTypeDescription
content_typestr = ""The content type.
cache_controlstr = ""The Cache-Control header.
content_dispositionstr = ""The Content-Disposition header.
content_encodingstr = ""The Content-Encoding header.
content_languagestr = ""The content language.
expiresstr = ""The Expires header.
storage_classstr = ""The storage class, such as STANDARD_IA.
aclstr = ""The canned ACL.
ssestr = ""Server side encryption: AES256 or aws:kms.
sse_kms_keystr = ""The KMS key.
taggingstr = ""The tags as a query string.
if_none_matchstr = ""With *, write only when the object does not exist.
if_matchstr = ""Only when the ETag matches.
checksum_md5bool = falseSend the MD5 digest of the body.
checksum_sha256bool = falseSend the SHA-256 digest of the body.
unsigned_payloadbool = falseLeave the body unsigned.
metaHeadersThe x-amz-meta-* metadata.
part_sizeint = 0The part size for large files.

The example for this item is shown with the ones above: aws-Objects.salam

GetOptions

#
struct GetOptions

Options for reading an object.

NameTypeDescription
range_starti64 = -1The start of the range.
range_endi64 = -1The end of the range; -1 means to the end.
version_idstr = ""The version.
if_none_matchstr = ""When the ETag matches, a 304.
if_matchstr = ""Only when the ETag matches.
if_modified_sincestr = ""Only when it changed after this time.
if_unmodified_sincestr = ""Only when it has not changed since this time.
response_content_typestr = ""Overrides the content type of the response.
response_content_dispositionstr = ""Overrides the Content-Disposition of the response.
part_numberint = 0Only one part of a multipart object.

The example for this item is shown with the ones above: aws-Objects.salam

CopyOptions

#
struct CopyOptions

Options for copying.

NameTypeDescription
source_bucketstr = ""The source bucket; empty means the bucket of the configuration.
source_version_idstr = ""The source version.
replace_metadatabool = falseReplace the metadata instead of copying it.
content_typestr = ""The new content type.
cache_controlstr = ""The new Cache-Control.
content_dispositionstr = ""The new Content-Disposition.
storage_classstr = ""The storage class.
aclstr = ""The ACL.
ssestr = ""The encryption.
taggingstr = ""The tags.
if_matchstr = ""Only when the source ETag matches.
if_none_matchstr = ""Only when the source ETag does not match.
if_modified_sincestr = ""Only when the source changed.
if_unmodified_sincestr = ""Only when the source has not changed.
metaHeadersThe new metadata.

The example for this item is shown with the ones above: aws-Objects.salam

ObjectInfo

#
struct ObjectInfo

Information about one object.

NameTypeDescription
okbool = falseThe object exists.
statusint = 0The HTTP status code.
keystr = ""The key.
sizei64 = 0The size.
etagstr = ""The ETag.
content_typestr = ""The content type.
content_encodingstr = ""The Content-Encoding.
cache_controlstr = ""The Cache-Control.
content_dispositionstr = ""The Content-Disposition.
last_modifiedstr = ""When it last changed.
modified_epochi64 = 0The same in Unix seconds.
storage_classstr = ""The storage class.
version_idstr = ""The version.
ssestr = ""The encryption.
delete_markerbool = falseIt is a delete marker.
partsint = 0The number of parts.
metaHeadersThe metadata.
errorstr = ""The error message.
codestr = ""The service error code, such as NoSuchKey.

The example for this item is shown with the ones above: aws-Objects.salam

Credentials

#
struct Credentials

AWS credentials, static or temporary.

NameTypeDescription
okbool = falseCredentials were found.
access_keystr = ""The access key id.
secret_keystr = ""The secret key.
session_tokenstr = ""The session token for temporary credentials.
expiresstr = ""The expiry time in ISO 8601 form; empty for static credentials.
expires_epochi64 = 0The expiry time in Unix seconds.
sourcestr = ""The source, one of the SOURCE_... constants.
errorstr = ""The error message.
codestr = ""The service error code, such as NoSuchKey.

The example for this item is shown with the ones above: aws-Config.salam

Identity

#
struct Identity

The identity of the caller.

NameTypeDescription
okbool = falseIt succeeded.
accountstr = ""The account number.
arnstr = ""The ARN of the user or role.
user_idstr = ""The user id.
errorstr = ""The error message.
codestr = ""The service error code, such as NoSuchKey.

The example for this item is shown with the ones above: aws-Config.salam

Headers

#
struct Headers

A list of names and values, for headers, tags and attributes.

NameTypeDescription
namesVector<str>The names.
valuesVector<str>The values.

The example for this item is shown with the ones above: aws-Sign.salam

Request

#
struct Request

An S3 request before signing.

NameTypeDescription
methodstr = "GET"The HTTP method.
keystr = ""The object key.
bucketstr = ""The bucket; empty means the bucket of the configuration.
service_levelbool = falseThe request goes to the service itself, not to a bucket.
headersHeadersThe headers.
queryHeadersThe query parameters.
bodyvoid*The body pointer.
body_lenint = 0The body length.
body_hashstr = ""The body digest, or UNSIGNED-PAYLOAD.

The example for this item is shown with the ones above: aws-Sign.salam

Bytes

#
struct Bytes

A binary response.

NameTypeDescription
okbool = falseIt succeeded.
statusint = 0The HTTP status code.
datavoid*The data pointer; free it with FreeBytes.
lenint = 0The data length.
etagstr = ""The ETag.
headstr = ""The raw headers.
codestr = ""The service error code, such as NoSuchKey.
errorstr = ""The error message.

The example for this item is shown with the ones above: aws-Objects.salam

Constants and variables

S3_PART_MIN

#
const S3_PART_MIN: i32 = 5242880

The smallest size of every part except the last: 5 MB.

The example for this item is shown with the ones above: aws-Files.salam

S3_PART_MAX_COUNT

#
const S3_PART_MAX_COUNT: i32 = 10000

The largest number of parts: 10000.

The example for this item is shown with the ones above: aws-Files.salam

S3_PART_DEFAULT

#
const S3_PART_DEFAULT: i32 = 8388608

The default part size: 8 MB.

The example for this item is shown with the ones above: aws-Files.salam

SERVICE_S3

#
const SERVICE_S3: str = "s3"

The name of the S3 service in the signature.

The example for this item is shown with the ones above: aws-Sign.salam

ALGORITHM

#
const ALGORITHM: str = "AWS4-HMAC-SHA256"

The name of the Signature Version 4 algorithm.

The example for this item is shown with the ones above: aws-Sign.salam

EMPTY_SHA256

#
const EMPTY_SHA256: str = "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855"

The SHA-256 digest of an empty body.

The example for this item is shown with the ones above: aws-Sign.salam

UNSIGNED_PAYLOAD

#
const UNSIGNED_PAYLOAD: str = "UNSIGNED-PAYLOAD"

The value that stands in for the body digest so the body is not signed.

The example for this item is shown with the ones above: aws-Sign.salam

SOURCE_ENV

#
const SOURCE_ENV: str = "environment"

Credential source: the AWS_ACCESS_KEY_ID and AWS_SECRET_ACCESS_KEY environment variables.

The example for this item is shown with the ones above: aws-Config.salam

SOURCE_PROFILE

#
const SOURCE_PROFILE: str = "profile"

Credential source: a profile in ~/.aws/credentials.

The example for this item is shown with the ones above: aws-Config.salam

SOURCE_WEB_IDENTITY

#
const SOURCE_WEB_IDENTITY: str = "web-identity"

Credential source: a web identity token, such as a Kubernetes service account.

The example for this item is shown with the ones above: aws-Config.salam

SOURCE_CONTAINER

#
const SOURCE_CONTAINER: str = "container"

Credential source: the container role in ECS or EKS.

The example for this item is shown with the ones above: aws-Config.salam

SOURCE_INSTANCE

#
const SOURCE_INSTANCE: str = "instance"

Credential source: the EC2 instance role from the metadata service.

The example for this item is shown with the ones above: aws-Config.salam

SQS_VERSION

#
const SQS_VERSION: str = "2012-11-05"

The API version of the SQS service.

The example for this item is shown with the ones above: aws-Parse.salam

SQS_MAX_MESSAGES

#
const SQS_MAX_MESSAGES: i32 = 10

The most messages in one receive.

The example for this item is shown with the ones above: aws-Parse.salam

SQS_MAX_WAIT

#
const SQS_MAX_WAIT: i32 = 20

The longest long poll, in seconds.

The example for this item is shown with the ones above: aws-Parse.salam

SQS_MAX_BATCH

#
const SQS_MAX_BATCH: i32 = 10

The most messages in one batch.

The example for this item is shown with the ones above: aws-Parse.salam

STS_VERSION

#
const STS_VERSION: str = "2011-06-15"

The API version of the STS service.

The example for this item is shown with the ones above: aws-Config.salam

STS_MIN_DURATION

#
const STS_MIN_DURATION: i32 = 900

The shortest lifetime of temporary credentials: 900 seconds.

The example for this item is shown with the ones above: aws-Config.salam

STS_MAX_DURATION

#
const STS_MAX_DURATION: i32 = 43200

The longest lifetime: 43200 seconds.

The example for this item is shown with the ones above: aws-Config.salam

STS_DEFAULT_SKEW

#
const STS_DEFAULT_SKEW: i32 = 300

The default margin in seconds; credentials count as expired a little before they expire.

The example for this item is shown with the ones above: aws-Config.salam

Functions

S3List

#
func S3List(cfg: Config, o: ListOptions): ObjectList

One page of the object listing, with options.

The example for this item is shown with the ones above: aws-Objects.salam

S3ListPrefix

#
func S3ListPrefix(cfg: Config, prefix: str): ObjectList

The objects under a prefix: one page, at most 1000. Check truncated or use S3ListAll.

The example for this item is shown with the ones above: aws-Objects.salam

S3ListFolder

#
func S3ListFolder(cfg: Config, prefix: str): ObjectList

One "folder": the objects and subfolders with the / delimiter.

The example for this item is shown with the ones above: aws-Objects.salam

S3ListV1

#
func S3ListV1(cfg: Config, o: ListOptions, marker: str): ObjectList

The old version of listing, for services that lack version 2.

The example for this item is shown with the ones above: aws-Objects.salam

S3ListAll

#
func S3ListAll(cfg: Config, prefix: str): ObjectList

Fetches every page, one after the other, up to 100000 objects; truncated is set when it stopped there.

The example for this item is shown with the ones above: aws-Objects.salam

S3ListAllWith

#
func S3ListAllWith(cfg: Config, o: ListOptions): ObjectList

Every page, with options.

The example for this item is shown with the ones above: aws-Objects.salam

S3ListVersions

#
func S3ListVersions(cfg: Config, o: ListOptions, key_marker: str, version_marker: str): ObjectList

The versions and delete markers.

The example for this item is shown with the ones above: aws-Objects.salam

S3Keys

#
func S3Keys(cfg: Config, prefix: str): KeyList

All the keys under a prefix. A failed listing gives an empty list, not an error.

The example for this item is shown with the ones above: aws-Objects.salam

ListCount

#
func ListCount(l: ObjectList): int

The number of objects.

The example for this item is shown with the ones above: aws-Parse.salam

ListAt

#
func ListAt(l: ObjectList, i: int): ObjectEntry

Object number i.

The example for this item is shown with the ones above: aws-Parse.salam

ListPrefixCount

#
func ListPrefixCount(l: ObjectList): int

The number of prefixes.

The example for this item is shown with the ones above: aws-Parse.salam

ListPrefixAt

#
func ListPrefixAt(l: ObjectList, i: int): str

Prefix number i.

The example for this item is shown with the ones above: aws-Parse.salam

ListTotalSize

#
func ListTotalSize(l: ObjectList): i64

The sum of the sizes.

The example for this item is shown with the ones above: aws-Parse.salam

ListFree

#
func ListFree(l &: ObjectList)

Frees the list.

The example for this item is shown with the ones above: aws-Parse.salam

KeyCount

#
func KeyCount(k: KeyList): int

The number of keys.

The example for this item is shown with the ones above: aws-Parse.salam

KeyAt

#
func KeyAt(k: KeyList, i: int): str

Key number i.

The example for this item is shown with the ones above: aws-Parse.salam

NewKeyList

#
func NewKeyList(): KeyList

An empty list.

The example for this item is shown with the ones above: aws-Parse.salam

KeyPush

#
func KeyPush(k &: KeyList, key: str)

Adds a key.

The example for this item is shown with the ones above: aws-Parse.salam

KeyFree

#
func KeyFree(k &: KeyList)

Frees the list.

The example for this item is shown with the ones above: aws-Parse.salam

S3DeleteMany

#
func S3DeleteMany(cfg: Config, keys: KeyList): Result

Deletes the keys in batches of a thousand.

The example for this item is shown with the ones above: aws-Objects.salam

S3DeletePrefix

#
func S3DeletePrefix(cfg: Config, prefix: str): Result

Deletes every object under a prefix.

The example for this item is shown with the ones above: aws-Objects.salam

ListToResult

#
func ListToResult(l: ObjectList): Result

The state of a listing as a result.

The example for this item is shown with the ones above: aws-Parse.salam

ParseListing

#
func ParseListing(body: str, status: int): ObjectList

Reads the XML response of a listing.

The example for this item is shown with the ones above: aws-Parse.salam

ServiceEndpoint

#
func ServiceEndpoint(service: str, region: str): str

The regional address of a service.

The example for this item is shown with the ones above: aws-Config.salam

NewQueryCall

#
func NewQueryCall(service: str, action: str, version: str): Call

A call to a query API, such as SQS and STS, with Action and Version.

The example for this item is shown with the ones above: aws-Parse.salam

NewJsonCall

#
func NewJsonCall(service: str, target: str, json: str): Call

A call to a JSON 1.0 API, such as DynamoDB.

The example for this item is shown with the ones above: aws-Parse.salam

NewJson11Call

#
func NewJson11Call(service: str, target: str, json: str): Call

A call to a JSON 1.1 API, such as CloudWatch Logs.

The example for this item is shown with the ones above: aws-Parse.salam

NewRestCall

#
func NewRestCall(service: str, method: str, path: str): Call

A call to a REST API, such as Lambda.

The example for this item is shown with the ones above: aws-Parse.salam

CallParam

#
func CallParam(c &: Call, name: str, value: str)

Adds a form parameter.

The example for this item is shown with the ones above: aws-Parse.salam

CallParamInt

#
func CallParamInt(c &: Call, name: str, value: int)

A numeric parameter.

The example for this item is shown with the ones above: aws-Parse.salam

CallHeader

#
func CallHeader(c &: Call, name: str, value: str)

Adds a header.

The example for this item is shown with the ones above: aws-Parse.salam

CallQuery

#
func CallQuery(c &: Call, name: str, value: str)

A query string parameter.

The example for this item is shown with the ones above: aws-Parse.salam

CallBody

#
func CallBody(c &: Call, body: str, content_type: str)

The body with a content type.

The example for this item is shown with the ones above: aws-Parse.salam

CallRegion

#
func CallRegion(c &: Call, region: str)

The region of the call.

The example for this item is shown with the ones above: aws-Parse.salam

CallEndpoint

#
func CallEndpoint(c &: Call, endpoint: str)

The address of the call.

The example for this item is shown with the ones above: aws-Parse.salam

Invoke

#
func Invoke(cfg: Config, c: Call): Result

Signs and runs the call, and tries again on transient errors.

The example for this item is shown with the ones above: aws-Services.salam

ServiceErrorCode

#
func ServiceErrorCode(body: str): str

The error code from an XML or JSON service response.

The example for this item is shown with the ones above: aws-Parse.salam

ServiceErrorMessage

#
func ServiceErrorMessage(body: str, status: int): str

The error message; when the body is empty, a message from the status code.

The example for this item is shown with the ones above: aws-Parse.salam

CallFree

#
func CallFree(c &: Call)

Frees the call.

The example for this item is shown with the ones above: aws-Parse.salam

PreparedCall

#
func PreparedCall(cfg: Config, c: Call, at: i64): str

The signed HTTP text of the call at the given time, without sending it; for tests.

The example for this item is shown with the ones above: aws-Parse.salam

CallBodyText

#
func CallBodyText(c: Call): str

The body that will be sent.

The example for this item is shown with the ones above: aws-Parse.salam

S3CreateUpload

#
func S3CreateUpload(cfg: Config, key: str, o: PutOptions): Upload

Starts a multipart upload.

The example for this item is shown with the ones above: aws-Files.salam

S3UploadPart

#
func S3UploadPart(cfg: Config, u &: Upload, number: int, data: void*, n: int): Result

Sends one part and records it in the upload.

The example for this item is shown with the ones above: aws-Files.salam

S3UploadPartCopy

#
func S3UploadPartCopy(cfg: Config, u &: Upload, number: int, src_key: str, o: CopyOptions, start: i64, stop: i64): Result

Copies a range of another object as a part.

The example for this item is shown with the ones above: aws-Files.salam

S3CompleteUpload

#
func S3CompleteUpload(cfg: Config, u: Upload): Result

Turns the parts into one object.

The example for this item is shown with the ones above: aws-Files.salam

S3AbortUpload

#
func S3AbortUpload(cfg: Config, u: Upload): Result

Aborts the upload and removes the parts; abandoned parts cost money.

The example for this item is shown with the ones above: aws-Files.salam

S3ListParts

#
func S3ListParts(cfg: Config, key: str, upload_id: str): PartList

The parts of one upload.

The example for this item is shown with the ones above: aws-Files.salam

S3ListUploads

#
func S3ListUploads(cfg: Config, prefix: str): UploadList

The unfinished uploads of the bucket.

The example for this item is shown with the ones above: aws-Files.salam

S3PutLarge

#
func S3PutLarge(cfg: Config, key: str, data: void*, n: int, part_size: int, o: PutOptions): Result

Sends large data in parts automatically; when it fails, it aborts.

The example for this item is shown with the ones above: aws-Files.salam

S3CopyLarge

#
func S3CopyLarge(cfg: Config, src_key: str, dst_key: str, part_size: int, o: CopyOptions): Result

Copies an object larger than 5 GB, part by part.

The example for this item is shown with the ones above: aws-Files.salam

S3MultipartEtag

#
func S3MultipartEtag(data: void*, n: int, part_size: int): str

The ETag S3 gives a multipart upload with this part size; for checking integrity.

The example for this item is shown with the ones above: aws-Sign.salam

S3ContentHashMd5

#
func S3ContentHashMd5(data: void*, n: int): str

The hexadecimal MD5 digest of the data.

The example for this item is shown with the ones above: aws-Sign.salam

PartCount

#
func PartCount(p: PartList): int

The number of parts.

The example for this item is shown with the ones above: aws-Files.salam

PartAt

#
func PartAt(p: PartList, i: int): PartRef

Part number i.

The example for this item is shown with the ones above: aws-Files.salam

UploadCount

#
func UploadCount(u: UploadList): int

The number of uploads.

The example for this item is shown with the ones above: aws-Files.salam

UploadAt

#
func UploadAt(u: UploadList, i: int): UploadRef

Upload number i.

The example for this item is shown with the ones above: aws-Files.salam

UploadParts

#
func UploadParts(u: Upload): int

The number of parts sent.

The example for this item is shown with the ones above: aws-Files.salam

UploadBytes

#
func UploadBytes(u: Upload): i64

The bytes sent.

The example for this item is shown with the ones above: aws-Files.salam

UploadFreeParts

#
func UploadFreeParts(u &: Upload)

Frees the list of parts.

The example for this item is shown with the ones above: aws-Files.salam

S3UploadFile

#
func S3UploadFile(cfg: Config, key: str, path: str, o: PutOptions): TransferResult

Sends a file; a large file goes as a multipart upload automatically and the whole file is never loaded into memory.

The example for this item is shown with the ones above: aws-Files.salam

S3UploadFileAs

#
func S3UploadFileAs(cfg: Config, key: str, path: str, content_type: str): TransferResult

A file with a content type.

The example for this item is shown with the ones above: aws-Files.salam

S3DownloadFile

#
func S3DownloadFile(cfg: Config, key: str, path: str): TransferResult

Saves an object to a file.

The example for this item is shown with the ones above: aws-Files.salam

S3UploadDir

#
func S3UploadDir(cfg: Config, dir: str, prefix: str, o: PutOptions): DirResult

Sends every file of a folder under a prefix; the content type is guessed from the extension.

The example for this item is shown with the ones above: aws-Files.salam

S3DownloadPrefix

#
func S3DownloadPrefix(cfg: Config, prefix: str, dir: str): DirResult

Saves every object under a prefix into a folder.

The example for this item is shown with the ones above: aws-Files.salam

S3FileEtag

#
func S3FileEtag(path: str, part_size: int): str

The ETag S3 gives this file; for syncing without downloading.

The example for this item is shown with the ones above: aws-Files.salam

NewTags

#
func NewTags(): Headers

An empty tag list.

The example for this item is shown with the ones above: aws-Sign.salam

TagSet

#
func TagSet(h &: Headers, name: str, value: str)

Sets a tag.

The example for this item is shown with the ones above: aws-Sign.salam

TagString

#
func TagString(tags: Headers): str

The tags as a query string, for the x-amz-tagging header.

The example for this item is shown with the ones above: aws-Sign.salam

S3SetObjectTags

#
func S3SetObjectTags(cfg: Config, key: str, tags: Headers): Result

Replaces the object tags.

The example for this item is shown with the ones above: aws-Objects.salam

S3ObjectTags

#
func S3ObjectTags(cfg: Config, key: str): Headers

The object tags.

The example for this item is shown with the ones above: aws-Objects.salam

S3ObjectTagsVersion

#
func S3ObjectTagsVersion(cfg: Config, key: str, version_id: str): Headers

The tags of one version.

The example for this item is shown with the ones above: aws-Objects.salam

S3DeleteObjectTags

#
func S3DeleteObjectTags(cfg: Config, key: str): Result

Deletes the tags.

The example for this item is shown with the ones above: aws-Objects.salam

S3AddObjectTag

#
func S3AddObjectTag(cfg: Config, key: str, name: str, value: str): Result

Adds a tag and keeps the others.

The example for this item is shown with the ones above: aws-Objects.salam

S3SetObjectAcl

#
func S3SetObjectAcl(cfg: Config, key: str, acl: str): Result

Sets the canned ACL of the object.

The example for this item is shown with the ones above: aws-Objects.salam

S3ObjectAcl

#
func S3ObjectAcl(cfg: Config, key: str): str

The object ACL as XML.

The example for this item is shown with the ones above: aws-Objects.salam

S3MakePublic

#
func S3MakePublic(cfg: Config, key: str): Result

Makes the object readable by everyone.

The example for this item is shown with the ones above: aws-Objects.salam

S3MakePrivate

#
func S3MakePrivate(cfg: Config, key: str): Result

Makes the object private.

The example for this item is shown with the ones above: aws-Objects.salam

S3SetLegalHold

#
func S3SetLegalHold(cfg: Config, key: str, held: bool): Result

Turns a legal hold on or off; needs Object Lock.

The example for this item is shown with the ones above: aws-Objects.salam

S3LegalHold

#
func S3LegalHold(cfg: Config, key: str): bool

A legal hold is on.

The example for this item is shown with the ones above: aws-Objects.salam

S3SetRetention

#
func S3SetRetention(cfg: Config, key: str, mode: str, until_epoch: i64): Result

GOVERNANCE or COMPLIANCE retention until the given time.

The example for this item is shown with the ones above: aws-Objects.salam

S3CreateBucket

#
func S3CreateBucket(cfg: Config, bucket: str): Result

Creates a bucket; outside us-east-1 it sends the region too.

The example for this item is shown with the ones above: aws-Buckets.salam

S3CreateBucketAcl

#
func S3CreateBucketAcl(cfg: Config, bucket: str, acl: str): Result

A bucket with a canned ACL, such as private.

The example for this item is shown with the ones above: aws-Buckets.salam

S3DeleteBucket

#
func S3DeleteBucket(cfg: Config, bucket: str): Result

Deletes an empty bucket.

The example for this item is shown with the ones above: aws-Buckets.salam

S3HeadBucket

#
func S3HeadBucket(cfg: Config, bucket: str): Result

The bucket headers; for checking that it exists and is reachable.

The example for this item is shown with the ones above: aws-Buckets.salam

S3BucketExists

#
func S3BucketExists(cfg: Config, bucket: str): bool

The bucket exists and is reachable.

The example for this item is shown with the ones above: aws-Buckets.salam

S3ListBuckets

#
func S3ListBuckets(cfg: Config): BucketList

The buckets of the account.

The example for this item is shown with the ones above: aws-Buckets.salam

BucketCount

#
func BucketCount(l: BucketList): int

The number of buckets.

The example for this item is shown with the ones above: aws-Buckets.salam

BucketAt

#
func BucketAt(l: BucketList, i: int): BucketEntry

Bucket number i.

The example for this item is shown with the ones above: aws-Buckets.salam

BucketListFree

#
func BucketListFree(l &: BucketList)

Frees the list.

The example for this item is shown with the ones above: aws-Buckets.salam

S3BucketRegion

#
func S3BucketRegion(cfg: Config, bucket: str): str

The region of the bucket.

The example for this item is shown with the ones above: aws-Buckets.salam

S3SetVersioning

#
func S3SetVersioning(cfg: Config, bucket: str, enabled: bool): Result

Turns bucket versioning on or suspends it.

The example for this item is shown with the ones above: aws-Buckets.salam

S3Versioning

#
func S3Versioning(cfg: Config, bucket: str): str

The versioning state: Enabled, Suspended or empty.

The example for this item is shown with the ones above: aws-Buckets.salam

S3SetBucketTags

#
func S3SetBucketTags(cfg: Config, bucket: str, tags: Headers): Result

Replaces the bucket tags.

The example for this item is shown with the ones above: aws-Buckets.salam

S3BucketTags

#
func S3BucketTags(cfg: Config, bucket: str): Headers

The bucket tags.

The example for this item is shown with the ones above: aws-Buckets.salam

S3DeleteBucketTags

#
func S3DeleteBucketTags(cfg: Config, bucket: str): Result

Deletes the bucket tags.

The example for this item is shown with the ones above: aws-Buckets.salam

S3SetBucketPolicy

#
func S3SetBucketPolicy(cfg: Config, bucket: str, policy_json: str): Result

Sets the JSON policy of the bucket.

The example for this item is shown with the ones above: aws-Buckets.salam

S3BucketPolicy

#
func S3BucketPolicy(cfg: Config, bucket: str): str

The bucket policy.

The example for this item is shown with the ones above: aws-Buckets.salam

S3DeleteBucketPolicy

#
func S3DeleteBucketPolicy(cfg: Config, bucket: str): Result

Deletes the policy.

The example for this item is shown with the ones above: aws-Buckets.salam

S3SetBucketCors

#
func S3SetBucketCors(cfg: Config, bucket: str, origin: str, methods: str, max_age: int): Result

A CORS rule with an origin, methods and a max age; for direct uploads from the browser.

The example for this item is shown with the ones above: aws-Buckets.salam

S3BucketCors

#
func S3BucketCors(cfg: Config, bucket: str): str

The CORS configuration as XML.

The example for this item is shown with the ones above: aws-Buckets.salam

S3DeleteBucketCors

#
func S3DeleteBucketCors(cfg: Config, bucket: str): Result

Deletes the CORS configuration.

The example for this item is shown with the ones above: aws-Buckets.salam

S3SetLifecycle

#
func S3SetLifecycle(cfg: Config, bucket: str, config_xml: str): Result

Sets the XML lifecycle configuration.

The example for this item is shown with the ones above: aws-Buckets.salam

S3Lifecycle

#
func S3Lifecycle(cfg: Config, bucket: str): str

The lifecycle configuration.

The example for this item is shown with the ones above: aws-Buckets.salam

S3DeleteLifecycle

#
func S3DeleteLifecycle(cfg: Config, bucket: str): Result

Deletes the lifecycle.

The example for this item is shown with the ones above: aws-Buckets.salam

S3ExpiryRule

#
func S3ExpiryRule(prefix: str, days: int, abort_days: int): str

The XML of a rule that deletes the objects under a prefix after some days and aborts unfinished uploads.

The example for this item is shown with the ones above: aws-Parse.salam

NewConfig

#
func NewConfig(endpoint: str, bucket: str): Config

A configuration with an address and a bucket.

The example for this item is shown with the ones above: aws-Config.salam

WithCredentials

#
func WithCredentials(cfg: Config, access_key: str, secret_key: str): Config

The configuration with keys.

The example for this item is shown with the ones above: aws-Config.salam

Configured

#
func Configured(cfg: Config): bool

The address, the bucket and the keys are all set, or the configuration is anonymous. It is false without a bucket, even for SQS or STS.

The example for this item is shown with the ones above: aws-Config.salam

Failure

#
func Failure(reason: str): Result

A failed result with a reason.

The example for this item is shown with the ones above: aws-Config.salam

AmzDate

#
func AmzDate(epoch_seconds: i64): str

The time in the 20130524T000000Z form.

The example for this item is shown with the ones above: aws-Sign.salam

DateStamp

#
func DateStamp(amz_date: str): str

The date part, such as 20130524.

The example for this item is shown with the ones above: aws-Sign.salam

Scope

#
func Scope(date_stamp: str, region: str, service: str): str

The credential scope of the signature: date/region/service/aws4_request.

The example for this item is shown with the ones above: aws-Sign.salam

UriEncode

#
func UriEncode(s: str, keep_slash: bool): str

Percent encoding the AWS way; with the second flag, / is kept.

The example for this item is shown with the ones above: aws-Sign.salam

EncodeKey

#
func EncodeKey(key: str): str

Encodes an object key for the URL path.

The example for this item is shown with the ones above: aws-Sign.salam

Sha256Bytes

#
func Sha256Bytes(ptr: void*, n: int): str

The hexadecimal SHA-256 digest.

The example for this item is shown with the ones above: aws-Sign.salam

SignRequest

#
func SignRequest(cfg: Config, method: str, path: str, query: str, canonical_headers: str, signed_headers: str, payload_hash: str, epoch_seconds: i64): Signed

Builds a Signature Version 4 signature from the parts of the canonical request.

The example for this item is shown with the ones above: aws-Sign.salam

SignString

#
func SignString(cfg: Config, date_stamp: str, payload: str): str

Signs a string with the signing key of the day.

The example for this item is shown with the ones above: aws-Sign.salam

SignQueryHeaders

#
func SignQueryHeaders(cfg: Config, method: str, path: str, query: str, canonical_headers: str, signed_headers: str, epoch_seconds: i64): str

A query string signature with signed headers.

The example for this item is shown with the ones above: aws-Sign.salam

SignQuery

#
func SignQuery(cfg: Config, method: str, path: str, query: str, host: str, epoch_seconds: i64): str

The query string signature parameters for a presigned URL.

The example for this item is shown with the ones above: aws-Sign.salam

AwsEndpoint

#
func AwsEndpoint(region: str): str

The S3 address in one region.

The example for this item is shown with the ones above: aws-Config.salam

ForAws

#
func ForAws(region: str, bucket: str): Config

A configuration for Amazon S3 with the regional address and virtual host addressing.

The example for this item is shown with the ones above: aws-Config.salam

ForMinio

#
func ForMinio(endpoint: str, bucket: str): Config

A configuration for MinIO with path addressing.

The example for this item is shown with the ones above: aws-Config.salam

ForR2

#
func ForR2(account_id: str, bucket: str): Config

A configuration for Cloudflare R2 with the account id.

The example for this item is shown with the ones above: aws-Config.salam

ForSpaces

#
func ForSpaces(region: str, bucket: str): Config

A configuration for DigitalOcean Spaces.

The example for this item is shown with the ones above: aws-Config.salam

ForWasabi

#
func ForWasabi(region: str, bucket: str): Config

A configuration for Wasabi.

The example for this item is shown with the ones above: aws-Config.salam

ForBackblaze

#
func ForBackblaze(region: str, bucket: str): Config

A configuration for Backblaze B2.

The example for this item is shown with the ones above: aws-Config.salam

ForEndpoint

#
func ForEndpoint(endpoint: str, region: str, bucket: str): Config

A configuration for any S3 compatible service, with an address and a region.

The example for this item is shown with the ones above: aws-Config.salam

FromEnvironment

#
func FromEnvironment(bucket: str): Config

A configuration from environment variables, such as AWS_REGION and AWS_ENDPOINT_URL.

The example for this item is shown with the ones above: aws-Config.salam

CredentialsPath

#
func CredentialsPath(): str

The path of the credentials file, usually ~/.aws/credentials.

The example for this item is shown with the ones above: aws-Config.salam

ConfigPath

#
func ConfigPath(): str

The path of the config file, usually ~/.aws/config.

The example for this item is shown with the ones above: aws-Config.salam

FromProfile

#
func FromProfile(profile: str, bucket: str): Config

A configuration from one profile in the ~/.aws files.

The example for this item is shown with the ones above: aws-Files.salam

ParseIni

#
func ParseIni(text: str, section: str, key: str): str

The value of one key in one section of INI text.

The example for this item is shown with the ones above: aws-Config.salam

WithBucket

#
func WithBucket(cfg: Config, bucket: str): Config

The configuration with another bucket.

The example for this item is shown with the ones above: aws-Config.salam

WithSessionToken

#
func WithSessionToken(cfg: Config, token: str): Config

The configuration with a session token.

The example for this item is shown with the ones above: aws-Config.salam

WithRetry

#
func WithRetry(cfg: Config, attempts: int, base_ms: int): Config

The number of attempts and the base delay in milliseconds; the delay doubles every time.

The example for this item is shown with the ones above: aws-Config.salam

Describe

#
func Describe(cfg: Config): str

A description of the configuration that does not reveal the secret.

The example for this item is shown with the ones above: aws-Config.salam

FromEnvironmentCredentials

#
func FromEnvironmentCredentials(): Credentials

Reads the credentials from the environment variables.

The example for this item is shown with the ones above: aws-Services.salam

FromProfileCredentials

#
func FromProfileCredentials(profile: str, o: ChainOptions): Credentials

Reads the credentials from a profile, and assumes the role when the profile has one.

The example for this item is shown with the ones above: aws-Services.salam

FromWebIdentityCredentials

#
func FromWebIdentityCredentials(o: ChainOptions): Credentials

Assumes the AWS_ROLE_ARN role with the AWS_WEB_IDENTITY_TOKEN_FILE file.

The example for this item is shown with the ones above: aws-Services.salam

FromContainerCredentials

#
func FromContainerCredentials(timeout_ms: int): Credentials

Gets the credentials from the ECS or EKS container endpoint.

The example for this item is shown with the ones above: aws-Services.salam

FromInstanceCredentials

#
func FromInstanceCredentials(timeout_ms: int): Credentials

Gets the credentials from the EC2 metadata service with IMDSv2. AWS_EC2_METADATA_SERVICE_ENDPOINT replaces the address of the service.

The example for this item is shown with the ones above: aws-Services.salam

InstanceRegion

#
func InstanceRegion(timeout_ms: int): str

The region of the EC2 instance from the metadata service; an empty string outside EC2.

The example for this item is shown with the ones above: aws-Services.salam

DefaultChain

#
func DefaultChain(): ChainOptions

The default chain: environment, profile, web identity, container and instance, in that order, as in the official SDKs.

The example for this item is shown with the ones above: aws-Config.salam

ContainerChain

#
func ContainerChain(): ChainOptions

A chain for containers that does not ask the instance.

The example for this item is shown with the ones above: aws-Config.salam

Resolve

#
func Resolve(o: ChainOptions): Credentials

Tries the sources of the chain in order and returns the first credentials it finds.

The example for this item is shown with the ones above: aws-Services.salam

ResolveConfig

#
func ResolveConfig(bucket: str, region: str, o: ChainOptions): Config

Builds a ready configuration with the bucket, the region and the credentials of the chain.

The example for this item is shown with the ones above: aws-Services.salam

S3Url

#
func S3Url(cfg: Config, key: str): str

The public URL of the object.

The example for this item is shown with the ones above: aws-Presign.salam

S3Presign

#
func S3Presign(cfg: Config, method: str, key: str, expires: int): str

A presigned URL with a method and a lifetime; anyone who has the URL can use it until it expires.

The example for this item is shown with the ones above: aws-Presign.salam

S3PresignAt

#
func S3PresignAt(cfg: Config, method: str, key: str, expires: int, epoch_seconds: i64): str

Presigns at the given time; for tests.

The example for this item is shown with the ones above: aws-Presign.salam

S3PresignWith

#
func S3PresignWith(cfg: Config, method: str, key: str, o: PresignOptions, epoch_seconds: i64): str

Presigns with options.

The example for this item is shown with the ones above: aws-Presign.salam

S3PresignGet

#
func S3PresignGet(cfg: Config, key: str, expires: int): str

A URL for reading.

The example for this item is shown with the ones above: aws-Presign.salam

S3PresignPut

#
func S3PresignPut(cfg: Config, key: str, content_type: str, expires: int): str

A URL for a direct upload from the browser with a content type.

The example for this item is shown with the ones above: aws-Presign.salam

S3PresignDownload

#
func S3PresignDownload(cfg: Config, key: str, filename: str, expires: int): str

A download URL with a chosen file name.

The example for this item is shown with the ones above: aws-Presign.salam

S3PresignPost

#
func S3PresignPost(cfg: Config, key: str, o: PostOptions): PostForm

A POST form with a policy for uploading from the browser with size and type limits.

The example for this item is shown with the ones above: aws-Presign.salam

S3PresignPostAt

#
func S3PresignPostAt(cfg: Config, key: str, o: PostOptions, epoch_seconds: i64): PostForm

Like the function above, at the given time.

The example for this item is shown with the ones above: aws-Presign.salam

PostFormHtml

#
func PostFormHtml(f: PostForm, file_field: str): str

The HTML of the form with the hidden fields and a file field.

The example for this item is shown with the ones above: aws-Presign.salam

SqsQueueUrl

#
func SqsQueueUrl(cfg: Config, name: str): str

The URL of a queue by name.

The example for this item is shown with the ones above: aws-Services.salam

SqsCreateQueue

#
func SqsCreateQueue(cfg: Config, name: str, attributes: Headers): str

Creates a queue with attributes and returns its URL; a name ending in .fifo makes a FIFO queue.

The example for this item is shown with the ones above: aws-Services.salam

SqsDeleteQueue

#
func SqsDeleteQueue(cfg: Config, url: str): Result

Deletes a queue.

The example for this item is shown with the ones above: aws-Services.salam

SqsListQueues

#
func SqsListQueues(cfg: Config, prefix: str): QueueList

The queues with a prefix.

The example for this item is shown with the ones above: aws-Services.salam

QueueCount

#
func QueueCount(l: QueueList): int

The number of queues.

The example for this item is shown with the ones above: aws-Services.salam

QueueAt

#
func QueueAt(l: QueueList, i: int): str

The URL of queue number i.

The example for this item is shown with the ones above: aws-Services.salam

QueueListFree

#
func QueueListFree(l &: QueueList)

Frees the list.

The example for this item is shown with the ones above: aws-Services.salam

SqsSend

#
func SqsSend(cfg: Config, url: str, body: str): SendResult

Sends a message.

The example for this item is shown with the ones above: aws-Services.salam

SqsSendWith

#
func SqsSendWith(cfg: Config, url: str, m: OutMessage): SendResult

A message with a delay, a group and attributes.

The example for this item is shown with the ones above: aws-Services.salam

SqsSendCall

#
func SqsSendCall(url: str, m: OutMessage): Call

Builds the send call without sending it.

The example for this item is shown with the ones above: aws-Parse.salam

SqsReceive

#
func SqsReceive(cfg: Config, url: str, o: ReceiveOptions): MessageList

Receives messages; a message stays hidden from others until it is deleted or its visibility timeout ends.

The example for this item is shown with the ones above: aws-Services.salam

SqsReceiveCall

#
func SqsReceiveCall(url: str, o: ReceiveOptions): Call

Builds the receive call.

The example for this item is shown with the ones above: aws-Parse.salam

ParseReceive

#
func ParseReceive(body: str, status: int): MessageList

Reads the XML response of a receive.

The example for this item is shown with the ones above: aws-Parse.salam

SqsPoll

#
func SqsPoll(cfg: Config, url: str): MessageList

Waits for messages with the longest long poll.

The example for this item is shown with the ones above: aws-Services.salam

SqsReceiveBatch

#
func SqsReceiveBatch(cfg: Config, url: str, count: int): MessageList

Receives up to n messages.

The example for this item is shown with the ones above: aws-Services.salam

MessageCount

#
func MessageCount(l: MessageList): int

The number of messages.

The example for this item is shown with the ones above: aws-Parse.salam

MessageAt

#
func MessageAt(l: MessageList, i: int): Message

Message number i.

The example for this item is shown with the ones above: aws-Parse.salam

MessageListFree

#
func MessageListFree(l &: MessageList)

Frees the list.

The example for this item is shown with the ones above: aws-Parse.salam

MessageAttribute

#
func MessageAttribute(m: Message, name: str): str

A message attribute by name.

The example for this item is shown with the ones above: aws-Parse.salam

SqsDelete

#
func SqsDelete(cfg: Config, url: str, receipt: str): Result

Deletes a processed message; otherwise it shows up again.

The example for this item is shown with the ones above: aws-Services.salam

SqsDeleteBatch

#
func SqsDeleteBatch(cfg: Config, url: str, l: MessageList): Result

Deletes all the messages of the list at once.

The example for this item is shown with the ones above: aws-Services.salam

SqsChangeVisibility

#
func SqsChangeVisibility(cfg: Config, url: str, receipt: str, seconds: int): Result

Changes how long a message stays hidden; for long jobs.

The example for this item is shown with the ones above: aws-Services.salam

SqsRelease

#
func SqsRelease(cfg: Config, url: str, receipt: str): Result

Makes the message visible to others right away.

The example for this item is shown with the ones above: aws-Services.salam

SqsPurge

#
func SqsPurge(cfg: Config, url: str): Result

Removes every message of the queue.

The example for this item is shown with the ones above: aws-Services.salam

SqsAttributes

#
func SqsAttributes(cfg: Config, url: str): Headers

The queue attributes.

The example for this item is shown with the ones above: aws-Services.salam

SqsSetAttributes

#
func SqsSetAttributes(cfg: Config, url: str, attributes: Headers): Result

Sets the queue attributes.

The example for this item is shown with the ones above: aws-Services.salam

SqsDepth

#
func SqsDepth(cfg: Config, url: str): int

The approximate number of waiting messages.

The example for this item is shown with the ones above: aws-Services.salam

SqsRedrivePolicy

#
func SqsRedrivePolicy(dead_letter_arn: str, max_receives: int): str

A JSON policy that sends messages that failed several times to a dead letter queue.

The example for this item is shown with the ones above: aws-Parse.salam

SqsQueueArn

#
func SqsQueueArn(cfg: Config, url: str): str

The ARN of the queue.

The example for this item is shown with the ones above: aws-Services.salam

S3PutBytes

#
func S3PutBytes(cfg: Config, key: str, body: void*, n: int, content_type: str): Result

Writes binary data.

The example for this item is shown with the ones above: aws-Objects.salam

S3PutBytesWith

#
func S3PutBytesWith(cfg: Config, key: str, body: void*, n: int, o: PutOptions): Result

Like the function above, with options.

The example for this item is shown with the ones above: aws-Objects.salam

S3Put

#
func S3Put(cfg: Config, key: str, body: str, content_type: str): Result

Writes text.

The example for this item is shown with the ones above: aws-Objects.salam

S3PutWith

#
func S3PutWith(cfg: Config, key: str, body: str, o: PutOptions): Result

Text with options.

The example for this item is shown with the ones above: aws-Objects.salam

S3Get

#
func S3Get(cfg: Config, key: str): Result

Reads an object as text. The body is a str and stops at the first zero byte; use S3GetBytes for binary data.

The example for this item is shown with the ones above: aws-Objects.salam

S3GetWith

#
func S3GetWith(cfg: Config, key: str, o: GetOptions): Result

With options.

The example for this item is shown with the ones above: aws-Objects.salam

S3GetBytes

#
func S3GetBytes(cfg: Config, key: str): Bytes

Reads an object as binary.

The example for this item is shown with the ones above: aws-Objects.salam

S3GetBytesWith

#
func S3GetBytesWith(cfg: Config, key: str, o: GetOptions): Bytes

Binary with options.

The example for this item is shown with the ones above: aws-Objects.salam

S3GetRange

#
func S3GetRange(cfg: Config, key: str, start: i64, stop: i64): Bytes

A range of bytes, from the start to the end, the end included.

The example for this item is shown with the ones above: aws-Objects.salam

S3Head

#
func S3Head(cfg: Config, key: str): Result

The object headers without the body.

The example for this item is shown with the ones above: aws-Objects.salam

S3Stat

#
func S3Stat(cfg: Config, key: str): ObjectInfo

Information about the object.

The example for this item is shown with the ones above: aws-Objects.salam

S3StatVersion

#
func S3StatVersion(cfg: Config, key: str, version_id: str): ObjectInfo

Information about one version.

The example for this item is shown with the ones above: aws-Objects.salam

S3Delete

#
func S3Delete(cfg: Config, key: str): Result

Deletes the object; a missing object is not an error.

The example for this item is shown with the ones above: aws-Objects.salam

S3DeleteVersion

#
func S3DeleteVersion(cfg: Config, key: str, version_id: str): Result

Deletes one version.

The example for this item is shown with the ones above: aws-Objects.salam

S3Exists

#
func S3Exists(cfg: Config, key: str): bool

The object exists.

The example for this item is shown with the ones above: aws-Objects.salam

S3Size

#
func S3Size(cfg: Config, key: str): i64

The size of the object; -1 when it does not exist.

The example for this item is shown with the ones above: aws-Objects.salam

S3Copy

#
func S3Copy(cfg: Config, src_key: str, dst_key: str): Result

A copy inside the server, without downloading.

The example for this item is shown with the ones above: aws-Objects.salam

S3CopyWith

#
func S3CopyWith(cfg: Config, src_key: str, dst_key: str, o: CopyOptions): Result

A copy with options.

The example for this item is shown with the ones above: aws-Objects.salam

S3Move

#
func S3Move(cfg: Config, src_key: str, dst_key: str): Result

Copies, then deletes the source.

The example for this item is shown with the ones above: aws-Objects.salam

S3Touch

#
func S3Touch(cfg: Config, key: str, o: CopyOptions): Result

Copies the object onto itself so its time and metadata are refreshed.

The example for this item is shown with the ones above: aws-Objects.salam

S3Restore

#
func S3Restore(cfg: Config, key: str, days: int, tier: str): Result

Brings a Glacier object back for some days; tier is one of Expedited, Standard or Bulk.

The example for this item is shown with the ones above: aws-Objects.salam

S3ContentHash

#
func S3ContentHash(body: void*, n: int): str

The hexadecimal SHA-256 digest, for the signature header.

The example for this item is shown with the ones above: aws-Sign.salam

S3ContentMd5

#
func S3ContentMd5(body: void*, n: int): str

The MD5 in Base64 for the Content-MD5 header.

The example for this item is shown with the ones above: aws-Sign.salam

S3ChecksumSha256

#
func S3ChecksumSha256(body: void*, n: int): str

The SHA-256 in Base64 for the checksum header.

The example for this item is shown with the ones above: aws-Sign.salam

S3ObjectChecksum

#
func S3ObjectChecksum(cfg: Config, key: str): str

The digest S3 keeps for the object.

The example for this item is shown with the ones above: aws-Objects.salam

StsEndpoint

#
func StsEndpoint(region: str): str

The regional address of the STS service.

The example for this item is shown with the ones above: aws-Config.salam

AssumeRole

#
func AssumeRole(cfg: Config, role_arn: str, session_name: str, duration: int): Credentials

Assumes a role and returns its temporary credentials.

The example for this item is shown with the ones above: aws-Services.salam

AssumeRoleWith

#
func AssumeRoleWith(cfg: Config, role_arn: str, session_name: str, duration: int, external_id: str, policy_arn: str): Credentials

Like the function above, with an external id and a limiting policy.

The example for this item is shown with the ones above: aws-Services.salam

AssumeRoleWithWebIdentity

#
func AssumeRoleWithWebIdentity(cfg: Config, role_arn: str, session_name: str, web_identity_token: str, duration: int): Credentials

Assumes a role with an OIDC token, from GitHub Actions for instance; no keys needed.

The example for this item is shown with the ones above: aws-Services.salam

GetSessionToken

#
func GetSessionToken(cfg: Config, duration: int, mfa_serial: str, mfa_code: str): Credentials

Temporary credentials, with an MFA code when needed.

The example for this item is shown with the ones above: aws-Services.salam

GetFederationToken

#
func GetFederationToken(cfg: Config, name: str, policy_json: str, duration: int): Credentials

Temporary credentials for an outside user with the given policy.

The example for this item is shown with the ones above: aws-Services.salam

GetCallerIdentity

#
func GetCallerIdentity(cfg: Config): Identity

The account and ARN of the current credentials; for testing keys.

The example for this item is shown with the ones above: aws-Services.salam

Apply

#
func Apply(cfg: Config, creds: Credentials): Config

Puts the credentials on a configuration, with the session token.

The example for this item is shown with the ones above: aws-Config.salam

StaticCredentials

#
func StaticCredentials(access_key: str, secret_key: str): Credentials

Static credentials from keys.

The example for this item is shown with the ones above: aws-Config.salam

Expired

#
func Expired(creds: Credentials, now: i64, skew: int): bool

The credentials are expired at the given time, with the margin.

The example for this item is shown with the ones above: aws-Config.salam

ExpiredNow

#
func ExpiredNow(creds: Credentials): bool

They are expired now.

The example for this item is shown with the ones above: aws-Config.salam

SecondsRemaining

#
func SecondsRemaining(creds: Credentials, now: i64): i64

The seconds left until expiry; -1 for static credentials.

The example for this item is shown with the ones above: aws-Config.salam

DescribeCredentials

#
func DescribeCredentials(creds: Credentials): str

A description of the credentials that does not reveal the secret; for logs.

The example for this item is shown with the ones above: aws-Config.salam

ParseCredentials

#
func ParseCredentials(body: str, status: int, source: str): Credentials

Turns an STS XML response into credentials.

The example for this item is shown with the ones above: aws-Config.salam

NewHeaders

#
func NewHeaders(): Headers

An empty list.

The example for this item is shown with the ones above: aws-Sign.salam

HeaderSet

#
func HeaderSet(h &: Headers, name: str, value: str)

Sets a value; names match regardless of letter case.

The example for this item is shown with the ones above: aws-Sign.salam

HeaderAdd

#
func HeaderAdd(h &: Headers, name: str, value: str)

Adds the name and value, even when the name repeats.

The example for this item is shown with the ones above: aws-Sign.salam

HeaderGet

#
func HeaderGet(h: Headers, name: str): str

The value of the first matching name.

The example for this item is shown with the ones above: aws-Sign.salam

HeaderHas

#
func HeaderHas(h: Headers, name: str): bool

The name is present.

The example for this item is shown with the ones above: aws-Sign.salam

HeaderCount

#
func HeaderCount(h: Headers): int

The count.

The example for this item is shown with the ones above: aws-Sign.salam

HeaderNameAt

#
func HeaderNameAt(h: Headers, i: int): str

Name number i.

The example for this item is shown with the ones above: aws-Sign.salam

HeaderValueAt

#
func HeaderValueAt(h: Headers, i: int): str

Value number i.

The example for this item is shown with the ones above: aws-Sign.salam

HeaderFree

#
func HeaderFree(h &: Headers)

Frees the list.

The example for this item is shown with the ones above: aws-Sign.salam

NewRequest

#
func NewRequest(method: str, key: str): Request

A request for a key in the bucket of the configuration.

The example for this item is shown with the ones above: aws-Sign.salam

NewBucketRequest

#
func NewBucketRequest(method: str, bucket: str, key: str): Request

A request for another bucket.

The example for this item is shown with the ones above: aws-Sign.salam

NewServiceRequest

#
func NewServiceRequest(method: str): Request

A request to the service itself, such as listing the buckets.

The example for this item is shown with the ones above: aws-Sign.salam

SetQuery

#
func SetQuery(r &: Request, name: str, value: str)

A query parameter.

The example for this item is shown with the ones above: aws-Sign.salam

SetQueryInt

#
func SetQueryInt(r &: Request, name: str, value: int)

A numeric query parameter.

The example for this item is shown with the ones above: aws-Sign.salam

SetFlag

#
func SetFlag(r &: Request, name: str)

A parameter without a value, such as ?acl.

The example for this item is shown with the ones above: aws-Sign.salam

SetHeader

#
func SetHeader(r &: Request, name: str, value: str)

A request header.

The example for this item is shown with the ones above: aws-Sign.salam

SetBody

#
func SetBody(r &: Request, p: void*, n: int)

A binary body; its digest is computed.

The example for this item is shown with the ones above: aws-Sign.salam

SetText

#
func SetText(r &: Request, s: str)

A text body.

The example for this item is shown with the ones above: aws-Sign.salam

SetUnsignedPayload

#
func SetUnsignedPayload(r &: Request)

Leaves the body unsigned; for large bodies over HTTPS.

The example for this item is shown with the ones above: aws-Sign.salam

Do

#
func Do(cfg: Config, r: Request): Result

Signs and runs the request.

The example for this item is shown with the ones above: aws-Services.salam

DoBytes

#
func DoBytes(cfg: Config, r: Request): Bytes

Like the function above, with a binary response.

The example for this item is shown with the ones above: aws-Services.salam

FreeBytes

#
func FreeBytes(b &: Bytes)

Frees the response data.

The example for this item is shown with the ones above: aws-Objects.salam

ResultHeader

#
func ResultHeader(r: Result, name: str): str

One header of the response.

The example for this item is shown with the ones above: aws-Objects.salam

BytesHeader

#
func BytesHeader(b: Bytes, name: str): str

One header of a binary response.

The example for this item is shown with the ones above: aws-Objects.salam

ResultErrorCode

#
func ResultErrorCode(body: str): str

The error code from an XML body.

The example for this item is shown with the ones above: aws-Sign.salam

ResultErrorMessage

#
func ResultErrorMessage(body: str, status: int): str

The error message from the body, or from the status code.

The example for this item is shown with the ones above: aws-Sign.salam

ResultTag

#
func ResultTag(body: str, tag: str): str

The text of the first XML element with this name.

The example for this item is shown with the ones above: aws-Sign.salam

Unquote

#
func Unquote(s: str): str

Removes the quotes on both sides; for ETags.

The example for this item is shown with the ones above: aws-Sign.salam

CanonicalRequest

#
func CanonicalRequest(cfg: Config, r: Request, at: i64): str

The Signature Version 4 canonical request; for debugging a SignatureDoesNotMatch error.

The example for this item is shown with the ones above: aws-Sign.salam

PreparedHead

#
func PreparedHead(cfg: Config, r: Request, at: i64): str

The signed HTTP headers of the request, without sending it.

The example for this item is shown with the ones above: aws-Sign.salam