> ## Documentation Index
> Fetch the complete documentation index at: https://docs.result.dev/llms.txt
> Use this file to discover all available pages before exploring further.

# Storage

> File uploads, downloads and signed URLs.

Create the bucket once (CLI), then upload from the app:

```bash theme={"dark"}
npx @resultdev/cli storage create-bucket uploads          # public
npx @resultdev/cli storage create-bucket private-docs --private
```

```ts theme={"dark"}
const { data } = await backend.storage.from("uploads").uploadAuto(file);
// data.key + data.url - save both to your database; data.url is directly
// usable for public buckets
```

<Warning>
  Uploads and `list()` require a signed-in user - anonymous calls are rejected.
  Sign the user up or in first.
</Warning>

## All operations

```ts theme={"dark"}
await backend.storage.from("uploads").upload("avatars/me.png", file); // choose the key
const { data: blob } = await backend.storage.from("uploads").download(key);
await backend.storage.from("uploads").remove(key);
```

## Private buckets

Hand out expiring links instead of raw URLs:

```ts theme={"dark"}
const { data: signed } = await backend.storage
  .from("private-docs").createSignedUrl(key, 3600); // seconds
```
