# Media

> Store heavy files (images, videos, sounds, PDF) in object storage with a description, find them again, share them privately or publicly with vg media.

Source: https://docs.ventgris.com/workspace/media

Media is where the heavy files of a workspace live: images, videos, sounds, PDF, decks and archives. Each file goes to object storage instead of the disk of the machine, and gets a row that says what it shows and what it is for. The agent finds a file again by asking (`vg media find "workshop poster"`), not by walking folders. Use it for anything large that must stay available, or that you want to hand out through a link.

Media has no screen in the interface. You and the agent use it through the `vg media` commands, in a session or in a [terminal](https://docs.ventgris.com/workspace/terminals.md).

## Check that media storage is available

Media storage is set up per workspace machine. When it is not set up, every `vg media` command answers:

```text
media storage is not configured on this instance ([media] in vgd.toml)
```

The rest of the workspace works normally. Heavy files then stay where they are, in the workspace folder (see [Files and editor](https://docs.ventgris.com/workspace/files-and-editor.md)), and count against the disk of the machine.

To check, run any read command:

```bash
vg media find --limit 1
```

If it prints `no media found` or a list, media storage is ready.

> [!NOTE]
> Without a public bucket, `--public` is refused with `no public bucket is configured`. Private storage and signed links still work.

## How media storage works

| Part | What it does |
|---|---|
| Private bucket | Holds every media unless you make it public. Read only through signed links that expire |
| Public bucket | Holds the media you made public. Served by a CDN address that anyone can open |
| Row in the workspace database | Id, name, kind, size, SHA-256, title, description, usage, tags, project, source, who stored it, when, where it is used |
| Search index | Full text over name, title, description, usage, tags and project, without accents |

A media is **private by default**. Make it public only when it is meant to be seen: a visual for a post, a cover, a sound of a public library. Keep contracts, data rooms, raw interview footage, photos of people and anything with personal data private.

The object key is `<workspace id>/<yyyy>/<mm>/<media id><.ext>`. The name of the stored object is the media id, never the original file name: renaming a media breaks no link, and a key reveals nothing about what the file holds.

The storage key belongs to the machine. The agent never sees it: `vg media` asks the workspace daemon, which reads the file and streams it to the bucket in chunks. A large video is never held in memory.

## Store a file

```bash
vg media put FILE --desc "what it shows" --usage "what it is for" [--title T] [--tags a,b] [--project P] [--source S] [--name N] [--public]
```

Example:

```bash
vg media put projects/events/poster-v3.png \
  --desc "Poster of the pitch workshop, blue background, three speakers" \
  --usage "Cover of the event page and the LinkedIn post of 2026-12-04" \
  --tags poster,workshop --public
```

| Flag | Required | Rule |
|---|---|---|
| `FILE` | yes | A file inside the workspace. A path outside it is refused (`the file is a path inside the workspace`) |
| `--desc` | yes | What the file shows. At least 10 characters, at most 2000 |
| `--usage` | yes | What it is for, why it exists. At least 10 characters, at most 1000 |
| `--title` | no | A short title |
| `--tags` | no | Comma-separated. Lowercased, 40 characters each, 20 tags at most, duplicates removed |
| `--project` | no | A workspace folder the media belongs to. Default: the folder of the file |
| `--source` | no | Where it comes from (a generator and its prompt, a site). Default: `upload` |
| `--name` | no | The name shown in lists. Default: the file name |
| `--public` | no | Store it in the public bucket and print its CDN address |

What `put` prints:

- one line: `ID  KIND  VISIBILITY  SIZE  NAME  [PROJECT]`;
- for a public media, its address on the CDN;
- for a private one, the reminder ``private: `vg media link ID` gives a signed link``.

The kind is set from the file type: `image`, `video`, `audio`, `pdf`, `document` (office files, `.md`, `.txt`, `.key`, `.pages`), `archive` (`.zip`, `.tar`, `.gz`, `.tgz`, `.7z`) or `other`.

### Why a description and a usage are required

`put` refuses a file without both:

```text
--desc "what it shows" and --usage "what it is for" are required: they are how the media is found again
```

An undescribed media is a media nobody finds. Write the description for someone who cannot see the file, and the usage for someone who wonders whether it can be deleted.

### Duplicates

The same bytes are stored once. If a file with the same SHA-256 already exists, `put` uploads nothing and returns the existing media, prefixed with `already stored, nothing uploaded:`.

### Errors when storing

| Message | Cause | What to do |
|---|---|---|
| `the file cannot be read: PATH` | The path does not exist or is not readable | Check the path from the workspace root |
| `PATH is not a regular file` | A folder or a special file | Store files one by one, or use `vg media import` for a folder |
| `PATH is empty` | Zero bytes | Nothing to store |
| `PATH is larger than 5120 MB, the most one media holds` | Over 5 GB | Keep files this large in another storage (a shared drive) and write in the project where they are |
| `PATH changed while it was read: try again once it is written` | The file was still being written | Wait until it is complete, then run `put` again |

## Find a media

```bash
vg media find ["words"] [--kind image|video|audio|pdf|document] [--project P] [--tag T] [--public|--private] [--limit N]
```

The words are matched against name, title, description, usage, tags and project, accents ignored: `vg media find "affiche workshop"` finds "Affiches du workshop pitch". Without words, `find` lists the most recent media that match the filters.

| Flag | Effect |
|---|---|
| `--kind` | One kind only |
| `--project` | One project folder |
| `--tag` | Media carrying this tag |
| `--public` or `--private` | One visibility. Not both |
| `--limit` | 20 by default, 200 at most |

Each result shows the media line, then its description and its usage on two indented lines. With no match it prints `no media found`.

## Read one media

```bash
vg media show ID
```

Shows the media line, title, description, usage, tags, MIME type, SHA-256, source and the path it was read from, when and by whom it was stored, its CDN address if it is public, and every place it is used.

## Get a link to a media

```bash
vg media link ID [--ttl 1h]
```

| Visibility | Link |
|---|---|
| Public | Its permanent CDN address |
| Private | A signed link that expires. 1 hour by default, 7 days at most (`--ttl 7d`). Longer is refused with `a signed link lasts seven days at most` |

The command prints the address and, for a signed link, `expires YYYY-MM-DD HH:MM`. Anyone who has a signed link can open the file until it expires: send it only to the people who should see the file.

## Change a description or the visibility

```bash
vg media set ID [--desc D] [--usage U] [--title T] [--tags a,b] [--project P] [--public|--private]
```

Flags left out keep their value. `--desc` and `--usage` keep their 10 character minimum. With no flag, the command answers `nothing to change`.

Changing the visibility copies the object to the other bucket, updates the row, then removes the old copy.

> [!WARNING]
> A public media is cached by the CDN for up to one day. Making it private again removes it from the public bucket at once, but a copy can stay reachable in the CDN cache for up to 24 hours. Do not make a file public if it must never be seen.

## Record where a media is used

```bash
vg media use ID WHERE [--note N]
```

`WHERE` is a path, an address or a post (500 characters at most). Recording the same place twice updates its note. `vg media show` lists the uses.

A media that is used somewhere is protected against deletion.

## Delete a media

```bash
vg media rm ID [--force]
```

`rm` deletes the object from storage and marks the row deleted. If the media has recorded uses, it is refused:

```text
the media is used in 2 place(s): see vg media show med_..., or delete with --force
```

Check those places first, then use `--force` if the file is really no longer needed.

## Move a folder of heavy files to media

```bash
vg media import DIR --usage "why these files exist" [--desc-prefix T] [--tags a,b] [--min-size 1MB] [--all] [--keep] [--dry-run]
```

`import` walks a workspace folder and stores every heavy file in it. Then, unless you pass `--keep`, it replaces each stored file with a small `NAME.media.json` next to where the file was. The folder stays readable and light.

| Flag | Effect |
|---|---|
| `--usage` | Required. Applied to every file |
| `--desc-prefix` | Text put before the generated description |
| `--tags` | Tags applied to every file |
| `--min-size` | Files smaller than this are skipped. Default `1MB`. Accepts `B`, `KB`, `MB`, `GB` |
| `--all` | Take every file type, not only the heavy ones |
| `--keep` | Leave the original files in place, write no `.media.json` |
| `--dry-run` | List what would be stored, with sizes, and change nothing |

Without `--all`, `import` takes these extensions: `.mp4 .mov .webm .mkv .m4v .avi`, `.mp3 .wav .m4a .ogg .flac .aac .aif .aiff`, `.png .jpg .jpeg .webp .gif .avif .heic .tif .tiff`, `.psd .ai .pdf .zip .pptx .key`. It never walks into `.git`, `node_modules`, `.venv`, `__pycache__`, `.next`, `dist` or `.cache`, and it skips files that already end in `.media.json`.

Run it in two steps:

1. Run `vg media import projects/film --usage "Rushes of the 30 s film" --dry-run` and read the list.
2. Run the same command without `--dry-run`.

It prints `N file(s), SIZE`, then one line per file: `[3/12] med_... projects/film/take-03.mov`. A file that fails is reported as `FAILED` and kept in place; the command ends with an error that counts the failures. Storage is checked before anything is walked or removed.

### The NAME.media.json file

`projects/film/take-03.mov` becomes `projects/film/take-03.mov.media.json`:

```json
{
  "media": "med_01JD...",
  "name": "take-03.mov",
  "size": 734003200,
  "sha256": "9f2c...",
  "note": "stored in object storage: vg media show med_01JD..., vg media link med_01JD..."
}
```

A public media also has a `url` field. To get the file back, run `vg media link` with the id and download it.

The description `import` writes is generic (`Fichier NAME du dossier FOLDER`). Refine the important ones with `vg media set ID --desc "..."`.

> [!AGENT]
> Store every heavy file you produce or receive with `vg media put`, with a real `--desc` (what it shows) and `--usage` (what it is for). Search with `vg media find` before generating or downloading something that may exist. Keep media private unless it is meant for the public; never make public a file with personal data, a contract or raw footage of people. Record each place you use a media with `vg media use`. Never `rm --force` a media without checking its uses with `vg media show`.

## What is recorded

Every store, every link to a private media, every change, every use and every deletion writes an entry in the audit journal, visible in [Activity](https://docs.ventgris.com/workspace/activity.md).

## Limits

| Limit | Value |
|---|---|
| Size of one media | 5 GB |
| Signed link | 1 hour by default, 7 days at most |
| Description | 10 to 2000 characters |
| Usage | 10 to 1000 characters |
| Tags | 20 per media, 40 characters each |
| Search results | 20 by default, 200 at most |
| CDN cache of a public media | up to 24 hours |

Media does not record the width, height or duration of a file.

## Related

- [Files and editor](https://docs.ventgris.com/workspace/files-and-editor.md)
- [Artifacts](https://docs.ventgris.com/workspace/artifacts.md)
- [vg CLI](https://docs.ventgris.com/agents/vg-cli.md)
- [Activity](https://docs.ventgris.com/workspace/activity.md)
- [Limits](https://docs.ventgris.com/reference/limits.md)
