Parameters
keystringrequiredWhere it goes. Slashes are characters, not folders.
contentstringText content, sent as it is.
contentBase64stringAnything binary. Base64 of the bytes.
contentTypestringWhat it is. Worth setting — it decides how a reader treats it.
// Text
await storage.run({ action: "upload", key: "notes/today.md",
content: "# Today\n\n…", contentType: "text/markdown" });
// Binary — base64, always
await storage.run({ action: "upload", key: "invoices/2026/01/a.pdf",
contentBase64: pdfBuffer.toString("base64"), contentType: "application/pdf" });
// { ok: true, key: "invoices/2026/01/a.pdf", size: 183204 }import base64
# Text
storage.run(action="upload", key="notes/today.md",
content="# Today\n\n…", contentType="text/markdown")
# Binary — base64, always
storage.run(action="upload", key="invoices/2026/01/a.pdf",
contentBase64=base64.b64encode(pdf_bytes).decode(), contentType="application/pdf")
# {"ok": True, "key": "invoices/2026/01/a.pdf", "size": 183204}A Buffer stringified goes through a text encoding that does not survive arbitrary bytes. The upload succeeds and the file is broken — which is the worst kind of failure, because nothing reports it.
It replaces without asking
An existing key is overwritten and the response looks the same as a fresh write. There is no previous version.
// Check first, if replacing would be wrong
const page = await storage.run({ action: "list", prefix: key });
if ((page.objects || []).some((o) => o.key === key)) {
throw new Error(`${key} already exists`);
}
await storage.run({ action: "upload", key, contentBase64, contentType });# Check first, if replacing would be wrong
page = storage.run(action="list", prefix=key)
if any(o["key"] == key for o in page.get("objects") or []):
raise FileExistsError(f"{key} already exists")
storage.run(action="upload", key=key, contentBase64=content_base64, contentType=content_type)Design the key before the first write
- Slashes make prefixes, and prefixes are the only grouping an object storage has.
- Put what you will filter by on the left:
invoices/2026/01/lists a month;01/2026/invoices/does not. - Keys are hard to change later — renaming is a copy and a delete, one object at a time.
Refused when the space is full
quota_exceeded, checked before the bytes are sent. usage before a large import is cheaper than finding out halfway.