> ## 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.

# Deliver media through your CDN

Studio can deliver different media roles through different providers while keeping one library, its original disks and its existing editor references. A thumbnail can use one CDN, a video another, and downloads can remain on the application server.

Delivery is optional and disabled by default. No CDN account, bucket or public hostname is created automatically. The application first checks workspace membership, permissions, the source and the selected version. It then either streams the object or returns a private, non-cacheable redirect to its configured provider. Listing a library does not contact the CDN or sign a URL for every card.

## Choose the access model

| Mode | Behavior |
| - | - |
| `per_request` | Default. Studio streams the file, or the supplied Cloudflare Worker checks Studio before every cache lookup. Removing access blocks the next request. |
| `expiry` | Studio issues a time-limited S3/CDN address. An already-issued address can remain usable until expiry. |
| `public` | Explicitly public objects with stable versioned URLs. Removing a Studio share does not make those objects private. |

A transfer already in progress cannot be taken back. None of these modes prevents someone from saving content they were allowed to preview. CDN cache invalidation does not replace access checks.

## Configure profiles

Add this section to `config/media-studio.php`, preserving your other settings:

```php theme={null}
'delivery' => [
    'enabled' => true,
    'roles' => [
        'thumbnail' => 'images',
        'preview' => 'images',
        'video' => 'server',
        'original' => 'private-storage',
        'archive' => 'private-storage',
        'rendition' => 'images',
    ],
    'profiles' => [
        'images' => [
            'driver' => 'bunny',
            'url' => 'https://images.example.com',
            'token_key' => env('STUDIO_BUNNY_TOKEN_KEY'),
            'revocation' => 'expiry',
            'ttl_seconds' => 120,
        ],
        'private-storage' => [
            'driver' => 's3',
            'revocation' => 'expiry',
            'ttl_seconds' => 120,
            'allowed_hosts' => ['my-private-bucket.s3.eu-north-1.amazonaws.com'],
        ],
    ],
    'disks' => [],
    'workspaces' => [],
    'presets' => [],
    'resolver' => null,
    'adapters' => [],
],
```

Use real hostnames matching the URLs generated by your S3 disk. S3-compatible endpoints and path-style URLs can use their own explicit allowed host. The S3 adapter requires Laravel's native S3 filesystem adapter; it is not installed automatically for applications that only use local disks. Signing does not fetch the file from S3.

The `url` represents the root of that Laravel disk as exposed by the CDN. Include any required CDN prefix. Studio URL-encodes each object path segment and does not concatenate an arbitrary caller-supplied URL. Production delivery requires HTTPS. Credentials stay in server configuration and must not be committed to your repository or sent to the frontend.

## Override a role

```php theme={null}
'disks' => [
    'video-s3' => ['video' => 'video-cdn'],
],
'workspaces' => [
    '01ARZ3NDEKTSV4RRFFQ69G5FAV' => ['thumbnail' => 'customer-cdn'],
],
'presets' => [
    'large' => 'large-image-cdn',
],
```

Precedence is global role, disk, workspace, preset, then optional resolver. Explicit `server` keeps that resource on Studio. Different roles may share one profile; you do not need duplicate configuration for identical providers.

For application-specific choices, implement `DeliveryProfileResolver::resolve(DeliveryResource $resource): ?string` and register its class as `delivery.resolver`. Return the name of an existing profile or `null` to retain the mapping. Keep this decision local and bounded; do not scan storage or call a remote service for every request.

## CloudFront

[Read CloudFront delivery](https://studio.bjanczak.com/cdn-cloudfront.md#cloudfront).

## Bunny

[Read Bunny delivery](https://studio.bjanczak.com/cdn-bunny.md#bunny).

## Cloudflare Worker with private R2

[Read Cloudflare Worker and private R2](https://studio.bjanczak.com/cdn-cloudflare-r2.md#cloudflare-worker-with-private-r2).

## Downloads and browser playback

S3 and the supplied Worker set content disposition explicitly. Other providers keep downloads on Studio unless their profile explicitly sets `download_headers => true`. Set that only after configuring and testing attachment response headers at the origin/CDN. Unsupported active inline formats, including HTML and SVG, retain Studio's attachment handling.

Long-running video players may request additional ranges after a signed URL expires. Choose an appropriate video TTL (maximum 3600 seconds), or keep video on `server` when it must remain valid for the authenticated session. Existing SDK/editor URLs continue to point to the Studio broker rather than persisting temporary addresses. Applications must not store the final redirect URL as the durable asset identity.

Configure CDN CORS for your exact application origin, including Range and exposed Content-Range/Content-Length/Content-Disposition headers. Credentialed browser requests require explicit origin support. Update your application's `img-src`, `media-src` and `connect-src` CSP directives. Studio's standalone guest page permits configured delivery origins for its thumbnails.

## Existing conversions and custom providers

The same broker runs after authorization for native renditions, directly projected Spatie conversions, external rendition providers, editor rendition links, originals, guest media and prepared archive results. It does not change which system owns or generates those files. Changes to files create new version keys; configure your CDN to retain the `fmsv` cache identity. For externally mutable storage, complete synchronization before expecting a new version to be delivered.

Implement `DeliveryAdapter::url(DeliveryResource $resource, array $profile, int $expiresAt): string` and register the class under `delivery.adapters` to add another provider. Return an HTTPS URL on an allowed host. Do not perform remote I/O while generating it. Unknown profiles, invalid signatures and invalid configuration do not silently fall back to public access.

No production provider credentials or CDN deployments are included in the package. Before enabling a profile, test its real origin mapping, CORS, cache policy, private origin protection, range playback and expiry on your deployment.


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