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

# References, usages and removed files

> Persist Studio-backed FLEX values and preserve ownership across form edits.

A selected Studio file is stored as an `assetId:versionId` string. A multiple field stores an ordered array. Choosing a file already in Studio resolves that reference. Upload file sends new bytes through Studio, which owns its storage and processing.

## Store the form value

For a multiple field, use a JSON-capable attribute with an array cast. Save validated form state and register its media usages together. Follow the complete [transactional usage example](https://studio.bjanczak.com/filament-media-references.md#save-a-gallery-with-its-usages), including registration in `media-studio.usage_owners`.

```php theme={null}
use UseFlex\MediaStudio\Integrations\Filament\StudioReference;

$reference = StudioReference::parse($storedValue);

if ($reference !== null) {
    $assetId = $reference['assetId'];
    $versionId = $reference['versionId'];
}
```

Use the resolved identifiers when registering usage. Fetch authorized delivery URLs when rendering. Expiring object-store addresses cannot serve as persistent references.

## Handle removed files

The field removes deleted Studio references during hydration and again before validation/save. If two of five selected assets are trashed, the remaining three are shown. Normal required and minimum-count rules still apply. Workspace access failures and backend errors require resolution rather than clearing the field.

Removing a selection from a form leaves the Studio original under Studio's lifecycle. Register or clear the owning record's usages when the record saves. To remove a managed asset itself, use Studio's authorized [trash workflow](https://studio.bjanczak.com/trash.md).

## Work with external sources

For Spatie-owned or application-owned media, expose the source through [Spatie integration](https://studio.bjanczak.com/spatie-media-library.md) or [application files](https://studio.bjanczak.com/application-files.md). Keep the original owner's mutation and cleanup policy. Configure the Studio workspace's [S3 disk](https://studio.bjanczak.com/storage-s3.md), [encryption](https://studio.bjanczak.com/encryption.md) and [renditions](https://studio.bjanczak.com/external-renditions.md) independently of the FLEX tile presentation.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.