await storage.run({ action: "object", key: "invoices/2026/01/a.pdf" });
// { key, size, contentType, base64: "…" }
await storage.run({ action: "object", key: "notes/today.md" });
// { key, size, contentType, text: "# Today…" }storage.run(action="object", key="invoices/2026/01/a.pdf")
# {"key", "size", "contentType", "base64": "…"}
storage.run(action="object", key="notes/today.md")
# {"key", "size", "contentType", "text": "# Today…"}text o base64
| Tu obte | Quando |
|---|---|
| text | Il tipo di contenuto è textual, o i bytes non conteniu null byte. |
| bâs64 | - Qualcosa di altro. |
Ambos i campi non sono mai presenti in una volta, quindi il test è qual ess.
const object = await storage.run({ action: "object", key });
const bytes = object.text !== undefined
? Buffer.from(object.text, "utf8")
: Buffer.from(object.base64, "base64");
await fs.writeFile(local, bytes);import base64
from pathlib import Path
obj = storage.run(action="object", key=key)
data = obj["text"].encode("utf-8") if "text" in obj else base64.b64decode(obj["base64"])
Path(local).write_bytes(data)Il contenit decide, non la proroga
Un file .dat che detende il testo limpide torna come testo, e che è la risposta acerta — legtura come base64 sarebbe un persy indown trip attraverso una codificazione che non ha mai tito.
Lee l'oggetto intero
Non è un interval. Verifica size da list prima di recuperare qualcosa di grande — i bytes passano per memoria de ambos lati.
const page = await storage.run({ action: "list", prefix });
const target = page.objects.find((o) => o.key === key);
if (target.size > 25 * 1024 * 1024) throw new Error("too large to read in one call");page = storage.run(action="list", prefix=prefix)
target = next(o for o in page["objects"] if o["key"] == key)
if target["size"] > 25 * 1024 * 1024:
raise ValueError("too large to read in one call")