# object

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

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

One object's content, as text or as base64 — decided by what is actually in it, not by its name.

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 or base64 {#which}

| You get | When |
| --- | --- |
| text | The content type is textual, or the bytes contain no null byte. |
| base64 | Anything else. |

Both fields are never present at once, so the test is which one exists.

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

> **The content decides, not the extension**
>
> A file named .dat holding plain text comes back as text, and that is the right answer — reading it as base64 would be a lossy round trip through an encoding it never had.

## It reads the whole object {#size}

There is no range. Check `size` from [list](/sdk/ref/connected-storage/run/list) before fetching something large — the bytes pass through memory on both sides.

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

- [list](/sdk/ref/connected-storage/run/list): Trouver la clé, et sa taille.
- [run()](/sdk/ref/connected-storage/run): Toutes les actions, les garde-fous et ce que chacune coûte.

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