# objete

Canonical URL: https://developers.iagenify.com/pt/sdk/ref/connected-storage/run/object/
Language: pt

`storage.run({ action: "object", key })`

Contenut d'un oggetto, come testo o come base64 — decide per quello che è realmente in esso, non per nome.

Status: object storage · free · lossless

```javascript
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…" }
```

## text o base64 {#which}

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

```javascript
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);
```

> **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 {#size}

Non è un interval. Verifica `size` da [list](/pt/sdk/ref/connected-storage/run/list) prima di recuperare qualcosa di grande — i bytes passano per memoria de ambos lati.

```javascript
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");
```

- [lista](/pt/sdk/ref/connected-storage/run/list): Trouve la clé, et sa taille.
- [run()](/pt/sdk/ref/connected-storage/run): Tutes les actions, les garde-fous et ce que chaque coute.

```python
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…"}
```

```python
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)
```

```python
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")
```
