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

# Attachments

> Descrive come inviare prompt con file, directory, selezioni e Blob allegati in Laravel Copilot SDK.

## File attachments

Specifica file o directory in un array come segue.

```php theme={null}
use Revolution\Copilot\Facades\Copilot;

$attachments = [
    [
        'type' => 'file',
        'path' => '/path/to/file.php',
        'displayName' => 'My File',// opzionale
    ],
    [
        'type' => 'directory',
        'path' => '/path/to/dir/',
        'displayName' => 'dir',// opzionale
    ],
    [
        'type' => 'selection',
        'filePath' => '/path/to/file.php',
        'displayName' => 'My File',// non omissibile qui
        'selection' => [
            'start' => ['line' => 1, 'character' => 10],
            'end' => ['line' => 5, 'character' => 10],
        ],
        'text' => '...',
    ],
    [
        'type' => 'blob',
        'data' => base64_encode(file_get_contents('/path/to/image.png')),
        'mimeType' => 'image/png',
        'displayName' => 'screenshot.png',// opzionale
    ],
];

$response = Copilot::run(prompt: '...', attachments: $attachments);
```

Poiché ricordare questo formato è difficile, sono disponibili degli helper per semplificarne l'uso.

```php theme={null}
use Revolution\Copilot\Facades\Copilot;
use Revolution\Copilot\Support\Attachment;

$attachments = [
    Attachment::file(path: '/path/to/file.php', displayName: 'My File'),
    Attachment::directory(path: '/path/to/dir/', displayName: 'dir'),
    Attachment::selection(filePath: '/path/to/file.php', displayName: 'My File', selection: ['start' => ['line' => 1, 'character' => 10], 'end' => ['line' => 5, 'character' => 10]], text: '...'),
    Attachment::blob(data: base64_encode(file_get_contents('/path/to/image.png')), mimeType: 'image/png', displayName: 'screenshot.png'),
];

$response = Copilot::run(prompt: '...', attachments: $attachments);
```

## Blob attachments

Il tipo `blob` viene utilizzato per allegare inline dati codificati in Base64. Puoi inviare direttamente dati binari come immagini senza I/O su disco.

```php theme={null}
use Revolution\Copilot\Support\Attachment;

// Allega un file immagine codificato in Base64
$attachment = Attachment::blob(
    data: base64_encode(file_get_contents('/path/to/image.png')),
    mimeType: 'image/png',
    displayName: 'screenshot.png',
);
```

<Info>
  `selection` non è ancora documentato nell'SDK ufficiale, quindi i dettagli non sono chiari. Anche `github_reference` mancano di informazioni ufficiali e sarà supportato in futuro.
</Info>

<Info>
  Per le informazioni più recenti fai riferimento al [repository GitHub](https://github.com/invokable/laravel-copilot-sdk).
</Info>


## Related topics

- [Invio di email](/it/mail.md)
- [Eventi di streaming](/it/packages/laravel-copilot-sdk/streaming-events.md)
- [Laravel Notification for Discord (Webhook)](/it/packages/laravel-notification-discord-webhook.md)
- [Driver Amazon Bedrock per Laravel AI SDK](/it/packages/laravel-amazon-bedrock.md)
