프롬프트 도감 › No.2663
Go 파일 API 가이드
Go Files API Reference
Go 언어로 파일 업로드와 조회 및 삭제 기능을 구현할 때 참고하는 기술 문서예요. 공식 SDK 메서드와 요청 매개변수 구조를 코드 예시와 함께 정리해둬요.
이럴 때 백엔드 API 개발, 파일 업로드 구현, SDK 연동 참고
도구 AI
프롬프트
<!--
name: "Data: Files API reference — Go"
description: "Go Files API reference including file upload, listing, deletion, and usage in messages"
ccVersion: "2.1.251"
-->
# Files API - Go
## Files API
> **Out of beta.** In current SDKs `client.Beta.Files` has breaking shape changes from previous versions, matching the stable `client.Files` - migrate per the Files API row in `shared/live-sources.md`. Examples below predate this.
Under `client.Beta.Files`. Method is **`Upload`** (NOT `New`/`Create`), params struct is `BetaFileUploadParams`. The `File` field takes an `io.Reader`; use `anthropic.File()` to attach a filename + content-type for the multipart encoding.
```go
f, _ := os.Open("./upload_me.txt")
defer f.Close()
meta, err := client.Beta.Files.Upload(ctx, anthropic.BetaFileUploadParams{
File: anthropic.File(f, "upload_me.txt", "text/plain"),
Betas: []anthropic.AnthropicBeta{anthropic.AnthropicBetaFilesAPI2025_04_14},
})
// meta.ID is the file_id to reference in subsequent message requests
```
Other `Beta.Files` methods: `List`, `Delete`, `Download`, `GetMetadata`.
---팁
- SDK 버전 업데이트에 따른 패키지 경로를 함께 확인해요.
- 멀티파트 업로드 시 파일 타입 지정을 잊지 마세요.
출처
권리: MIT; Piebald-AI/claude-code-system-prompts; 원문 출처 링크 참조. 수정·번역 여부는 카드 메타 참조.