Connecting
const bucket = await api.storage.connect({
label: "Archive",
type: "object",
provider: "s3",
endpoint: {
credentials: {
bucketName: "my-archive",
region: "eu-west-3",
accessKeyId: "…",
secretAccessKey: "…",
},
},
});bucket = api.storage.connect(
label="Archive",
type="object",
provider="s3",
endpoint={
"credentials": {
"bucketName": "my-archive",
"region": "eu-west-3",
"accessKeyId": "…",
"secretAccessKey": "…",
},
},
)credentials.bucketNamestringrequiredThe bucket.
credentials.regionstringus-east-1Where it lives. Part of the address and of the signature.
credentials.accessKeyIdstringrequiredThe access key.
credentials.secretAccessKeystringrequiredIts secret.
The region is signed into every request, so a bucket in eu-west-3 reached as us-east-1 is refused — and the refusal talks about the signature, not about the region. Set it explicitly whenever the bucket is not in the default one.
The five actions
| Call | Does |
|---|---|
{ action: "list", prefix, limit, recursive, continuationToken } | Lists keys and folders under a prefix. |
{ action: "overview" } | Top-level folders, with counts, bytes and a sample. |
{ action: "object", key } | Reads one object — text or base64. |
{ action: "upload", key, contentBase64 | content, contentType } | Writes one object. |
{ action: "delete", key } | Removes one object. |
Everything on the R2 page about folders, paging, binary content and key encoding applies identically here — the two share one implementation, and the shapes that come back are the same.
What the key needs to be allowed
| Action | Needs |
|---|---|
list · overview | listing the bucket |
object | reading an object |
upload | writing an object |
delete | deleting an object |
A key allowed to read but not to list makes object work while list is refused — which reads as « the bucket is empty » if you only ever call list. Grant listing, or work from keys you already hold.
Errors keep the provider's message
A refusal comes back as Échec du listage S3/R2 (HTTP 403) followed by the provider's own explanation, pulled out of its XML. That message is the fastest route to the cause: a missing permission, a wrong region, an expired key.
It is registered, not tested
connect() stores the credentials and returns. Nothing is verified until the first run() — see connect().