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

> Beschreibt, wie Sie im Laravel Copilot SDK Dateien, Verzeichnisse, Auswahlbereiche und Blobs anhängen und mit Prompts versenden.

## File attachments

Geben Sie Dateien oder Verzeichnisse wie folgt als Array an.

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

$attachments = [
    [
        'type' => 'file',
        'path' => '/path/to/file.php',
        'displayName' => 'My File',// optional
    ],
    [
        'type' => 'directory',
        'path' => '/path/to/dir/',
        'displayName' => 'dir',// optional
    ],
    [
        'type' => 'selection',
        'filePath' => '/path/to/file.php',
        'displayName' => 'My File',// hier nicht optional
        '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',// optional
    ],
];

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

Da sich ein solches Format schwer merken lässt, stehen Helper zur einfachen Nutzung bereit.

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

Der Typ `blob` wird verwendet, um Base64-kodierte Daten inline anzuhängen. So können Sie Binärdaten wie Bilder ohne Disk-I/O direkt senden.

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

// Bilddatei Base64-kodieren und anhängen
$attachment = Attachment::blob(
    data: base64_encode(file_get_contents('/path/to/image.png')),
    mimeType: 'image/png',
    displayName: 'screenshot.png',
);
```

<Info>
  Für `selection` gibt es im offiziellen SDK noch keine Dokumentation, daher sind die Details unklar. Auch zu `github_reference` fehlen offizielle Informationen; eine Unterstützung ist zukünftig geplant.
</Info>

<Info>
  Aktuelle Informationen finden Sie im [GitHub-Repository](https://github.com/invokable/laravel-copilot-sdk).
</Info>


## Related topics

- [E-Mail-Versand](/de/mail.md)
- [Laravel Notification für Discord (Webhook)](/de/packages/laravel-notification-discord-webhook.md)
- [Streaming-Ereignisse](/de/packages/laravel-copilot-sdk/streaming-events.md)
- [Laravel AI SDK](/de/ai-sdk.md)
- [Amazon-Bedrock-Treiber für das Laravel AI SDK](/de/packages/laravel-amazon-bedrock.md)
