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

> Explica cómo adjuntar ficheros, directorios, selecciones y blobs al enviar prompts con Laravel Copilot SDK.

## File attachments

Indica los ficheros o directorios como array, tal como se muestra a continuación.

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

$attachments = [
    [
        'type' => 'file',
        'path' => '/path/to/file.php',
        'displayName' => 'My File',// opcional
    ],
    [
        'type' => 'directory',
        'path' => '/path/to/dir/',
        'displayName' => 'dir',// opcional
    ],
    [
        'type' => 'selection',
        'filePath' => '/path/to/file.php',
        'displayName' => 'My File',// aquí no se puede omitir
        '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',// opcional
    ],
];

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

Como es difícil memorizar este formato, se ofrecen helpers para facilitar el 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

El tipo `blob` sirve para adjuntar datos codificados en Base64 en línea. Permite enviar directamente datos binarios como imágenes sin necesidad de I/O de disco.

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

// Adjunta una imagen codificada en Base64
$attachment = Attachment::blob(
    data: base64_encode(file_get_contents('/path/to/image.png')),
    mimeType: 'image/png',
    displayName: 'screenshot.png',
);
```

<Info>
  `selection` no está documentado todavía en el SDK oficial, por lo que los detalles se desconocen. `github_reference` tampoco tiene información oficial suficiente, por lo que se abordará más adelante.
</Info>

<Info>
  Consulta la información más reciente en el [repositorio de GitHub](https://github.com/invokable/laravel-copilot-sdk).
</Info>


## Related topics

- [Envío de correo](/es/mail.md)
- [Eventos de streaming](/es/packages/laravel-copilot-sdk/streaming-events.md)
- [Laravel Notification for Discord(Webhook)](/es/packages/laravel-notification-discord-webhook.md)
- [Laravel AI SDK](/es/ai-sdk.md)
- [Driver de Amazon Bedrock para Laravel AI SDK](/es/packages/laravel-amazon-bedrock.md)
