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

> Laravel Copilot SDK에서 파일, 디렉터리, 선택 범위, Blob을 첨부하여 프롬프트를 전송하는 방법을 설명합니다.

## File attachments

다음과 같이 파일 또는 디렉터리를 배열로 지정합니다.

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

$attachments = [
    [
        'type' => 'file',
        'path' => '/path/to/file.php',
        'displayName' => 'My File',// 생략 가능
    ],
    [
        'type' => 'directory',
        'path' => '/path/to/dir/',
        'displayName' => 'dir',// 생략 가능
    ],
    [
        'type' => 'selection',
        'filePath' => '/path/to/file.php',
        'displayName' => 'My File',// 여기는 생략 불가
        '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',// 생략 가능
    ],
];

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

이런 포맷을 외우기는 어렵기 때문에 쉽게 사용할 수 있도록 헬퍼를 제공하고 있습니다.

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

`blob` 타입은 Base64 인코딩된 데이터를 인라인으로 첨부할 때 사용합니다. 디스크 I/O 없이 이미지 등의 바이너리 데이터를 직접 전송할 수 있습니다.

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

// 이미지 파일을 Base64로 인코딩하여 첨부
$attachment = Attachment::blob(
    data: base64_encode(file_get_contents('/path/to/image.png')),
    mimeType: 'image/png',
    displayName: 'screenshot.png',
);
```

<Info>
  `selection`은 공식 SDK에 아직 문서가 없어 상세는 불명입니다. `github_reference`도 공식 정보가 부족하기 때문에 향후 지원 예정입니다.
</Info>

<Info>
  최신 정보는 [GitHub 저장소](https://github.com/invokable/laravel-copilot-sdk)를 참고하세요.
</Info>


## Related topics

- [스트리밍 이벤트](/ko/packages/laravel-copilot-sdk/streaming-events.md)
- [메일 전송](/ko/mail.md)
- [Laravel Notification for Discord(Webhook)](/ko/packages/laravel-notification-discord-webhook.md)
- [Laravel AI SDK](/ko/ai-sdk.md)
- [Laravel AI SDK용 Amazon Bedrock 드라이버](/ko/packages/laravel-amazon-bedrock.md)
