---
title: luna files
description: List, download, upload and delete the files in a luna's buckets, and sign a URL for one.
related:
  - /files-and-code/store-files
  - /develop/browse-a-lunas-data
  - /cli/data
---

`luna files` works with the files of one luna, in the buckets its code declares.

```bash
luna files list User u_42 uploads
```

## Reference

```bash
luna files <COMMAND>
```

Every subcommand names the luna by its type and key, and the bucket by its name. Each one also takes these options.

| Option | Type | Default | Does |
| --- | --- | --- | --- |
| `--dir <DIR>` | path | `.` | The app's folder. Its env file names the project and environment. |
| `--env <ENV>` | text | `LUNA_ENV`, then `production` | The environment, by name. |
| `--project <PROJECT>` | text | `LUNA_PROJECT` | The project, by name or as `organisation/project`. |
| `--tenant <TENANT>` | text | The environment's own | A tenant added to the environment, by name. |
| `--token <TOKEN>` | text | `LUNA_TOKEN`, then your login | An API token or account key to act with. |

### luna files list

Prints one folder of a bucket: the folders in it, then its files with their size and content type.

```bash
luna files list [OPTIONS] <TYPE> <KEY> <BUCKET> [FOLDER]
```

| Option | Type | Default | Does |
| --- | --- | --- | --- |
| `<TYPE>` | text | Required | The luna type, by name. |
| `<KEY>` | text | Required | The luna's key. |
| `<BUCKET>` | text | Required | The bucket, by name. |
| `[FOLDER]` | text | The top of the bucket | The folder to list, such as `photos/2026/`. |
| `--limit <LIMIT>` | number | `100` | How many folders and files to print, at most 1000. |
| `--json` | flag | Off | Prints the answer as JSON. |

### luna files get

Downloads a file.

```bash
luna files get [OPTIONS] <TYPE> <KEY> <BUCKET> <PATH>
```

| Option | Type | Default | Does |
| --- | --- | --- | --- |
| `<PATH>` | text | Required | The file's path in the bucket. |
| `-o`, `--output <OUTPUT>` | path | The file's name, in this folder | Where to write it. `-` writes it to standard output. |

### luna files put

Uploads a file to a path in a bucket, and replaces what is there.

```bash
luna files put [OPTIONS] <TYPE> <KEY> <BUCKET> <PATH> <FILE>
```

| Option | Type | Default | Does |
| --- | --- | --- | --- |
| `<PATH>` | text | Required | The path to store it at in the bucket. |
| `<FILE>` | path | Required | The file on this machine to upload. |
| `--type <CONTENT_TYPE>` | text | Guessed from the file's name | The content type to store with it. |

### luna files delete

Deletes a file. It asks first.

```bash
luna files delete [OPTIONS] <TYPE> <KEY> <BUCKET> <PATH>
```

| Option | Type | Default | Does |
| --- | --- | --- | --- |
| `<PATH>` | text | Required | The file's path in the bucket. |
| `--yes` | flag | Off | Deletes without asking. |

### luna files url

Prints a signed URL that downloads the file without a token, until it expires.

```bash
luna files url [OPTIONS] <TYPE> <KEY> <BUCKET> <PATH>
```

| Option | Type | Default | Does |
| --- | --- | --- | --- |
| `<PATH>` | text | Required | The file's path in the bucket. |
| `--expires <EXPIRES>` | duration | `1h` | How long the URL works, such as `90s`, `15m`, `2h` or `3d`. At most `7d`. |

## Good to know

- A key with one field is given as its value, such as `u_42`. A key with several fields is given as JSON, such as `'{"board":"b1","card":"c7"}'`.
- `put` guesses the content type from the extension: `png`, `jpg`, `gif`, `webp`, `svg`, `pdf`, `json`, `txt`, `md`, `log`, `csv`, `html`, `mp4` and `mp3`. Any other file is stored as `application/octet-stream` unless you pass `--type`.
- Anyone who has a URL from `url` can download the file until it expires. Pass the shortest `--expires` that does the job.
- `list`, `get` and `url` need the `data:read` scope. `put` and `delete` need `data:write`.
- Without a terminal to ask at, `delete` stops with exit code 6 unless you pass `--yes`.

:::warning
`put` replaces any file at the same path, and `delete` removes a file for good. Neither can be undone.
:::

## Examples

### List a folder

```bash
luna files list User u_42 uploads photos/2026/
```

### Print a text file

```bash
luna files get User u_42 uploads notes/today.txt -o -
```

### Upload a file with its content type

```bash
luna files put User u_42 uploads notes/today.txt ./today.txt --type text/plain
```

### Share a file for a day

```bash
luna files url User u_42 uploads photos/2026/me.png --expires 1d
```

### Delete a file in a script

```bash
luna files delete User u_42 uploads photos/2026/me.png --yes
```
