# Visuals: File downloader

Secure download button for a file already stored in the `media` table (Spatie Media Library). Use it to display existing attachments; use [File Uploader](../forms/file_uploader.md) when the user must upload new files, passing the same `media` id through `value`.

The plain media id is never rendered: `setValue()` caches it server-side (owner-checked) and the button carries only an HMAC signature bound to the component UUID, like table record signatures. On click the frontend calls `POST /kfw/downloader/get-url` with `uuid` + `signature`, which verifies and returns a single-use token URL (`GET /kfw/download/{token}`).

```php
{!! 
  \KFramework\Components\Visual\Downloader::make()
    ->setValue(1234)
!!}
```

**End-to-end example:** invoice attachment on a detail page.
```php
// Blade:
{!!
  \KFramework\Components\Visual\Downloader::make()
    ->setValue($invoice->media_id)
!!}

// Controller:
use KFramework\Components\Visual\Downloader;

$file = Downloader::make()->setValue($invoice->media_id);

return view('invoices.show', compact('file'));
```

---
## Usage

---
```php
{!! \KFramework\Components\Visual\Downloader::make() !!}
```
- Controller:
```php
Downloader::make()
```

---
## Standard attributes

---
- `uuid`
- `id`
- `classes`
- `extraAttributes`
- `value`
  - The value is an integer, precisely the `id` column of the table `media`. Setting this will automatically retrieve file name and download path.

See their usage and description [here](../basics.md).

---

## See also
- [Components basics](../basics.md)
- [File Uploader](../forms/file_uploader.md), [Card](card.md)
- [value](../shared_attributes/value.md)