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.

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

Types

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.
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

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

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
Outputtrue 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.
itemsVectorThe objects.
prefixesVectorThe 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.
itemsVectorThe 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
itemsVectorThe keys.

The example for this item is shown with the ones above: aws-Parse.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.
itemsVectorThe 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.
itemsVectorThe 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

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.
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
Output20130524T000000Z 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

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
Outputhttps://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

PartRef

struct PartRef
One uploaded part.
NameTypeDescription
numberint = 0The number, from 1.
etagstr = ""The ETag of the part.
sizei64 = 0The size.

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

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.
partsVectorThe 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.
itemsVectorThe 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.
itemsVectorThe 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

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.
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
Outputhttps://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.

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

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

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
namesVectorThe names.
valuesVectorThe 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

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

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

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

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

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.

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.

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.

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

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 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

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

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

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

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

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

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 and the keys are set, or the configuration is anonymous.

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

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.

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

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

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

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