Git 미확인 개체에 대한 REST API 엔드포인트
각 파일의 콘텐츠를 리포지토리에 저장하는 데 사용되는 개체 형식인 Git BLOB(Binary Large Object)와 상호 작용하려면 REST API를 사용하십시오.
Git Blob 정보
Git BLOB(Binary Large Object)은 각 파일의 콘텐츠를 리포지토리에 저장하는 데 사용되는 개체 형식입니다. 파일의 SHA-1 해시는 계산되어 BLOB 개체에 저장됩니다. 엔드포인트를 사용하면 GitHub에서 Git 데이터베이스에 BLOB 개체를 읽고 쓸 수 있습니다. BLOB은 사용자 지정 미디어 유형을 활용합니다. API에서 미디어 형식을 사용하는 방법에 대한 자세한 정보는 REST API 시작을(를) 참조하세요.
Create a blob
"Create a blob"에 대한 세분화된 액세스 토큰
이 엔드포인트는 다음 세분화된 토큰 형식에서 작동합니다.:
세분화된 토큰에는 다음 권한 집합이 있어야 합니다.:
- "Contents" repository permissions (write)
"Create a blob"에 대한 매개 변수
| 속성, 형식, 설명 | 
|---|
| acceptstringSetting to  | 
| 속성, 형식, 설명 | 
|---|
| ownerstring RequiredThe account owner of the repository. The name is not case sensitive. | 
| repostring RequiredThe name of the repository without the  | 
| 속성, 형식, 설명 | 
|---|
| contentstring RequiredThe new blob's content. | 
| encodingstringThe encoding used for  기본값:  | 
"Create a blob"에 대한 HTTP 응답 상태 코드
| 상태 코드 | 설명 | 
|---|---|
| 201 | Created | 
| 403 | Forbidden | 
| 404 | Resource not found | 
| 409 | Conflict | 
| 422 | Validation failed | 
"Create a blob"에 대한 코드 샘플
GHE.com에서 GitHub에 액세스하는 경우 api.github.com을 api.SUBDOMAIN.ghe.com의 엔터프라이즈 전용 하위 도메인으로 바꾸세요.
요청 예제
curl -L \
  -X POST \
  -H "Accept: application/vnd.github+json" \
  -H "Authorization: Bearer <YOUR-TOKEN>" \
  -H "X-GitHub-Api-Version: 2022-11-28" \
  https://api.github.com/repos/OWNER/REPO/git/blobs \
  -d '{"content":"Content of the blob","encoding":"utf-8"}'Response
Status: 201{
  "url": "https://api.github.com/repos/octocat/example/git/blobs/3a0f86fb8db8eea7ccbb9a95f325ddbedfb25e15",
  "sha": "3a0f86fb8db8eea7ccbb9a95f325ddbedfb25e15"
}Get a blob
The content in the response will always be Base64 encoded.
This endpoint supports the following custom media types. For more information, see "Media types."
- application/vnd.github.raw+json: Returns the raw blob data.
- application/vnd.github+json: Returns a JSON representation of the blob with- contentas a base64 encoded string. This is the default if no media type is specified.
Note This endpoint supports blobs up to 100 megabytes in size.
"Get a blob"에 대한 세분화된 액세스 토큰
이 엔드포인트는 다음 세분화된 토큰 형식에서 작동합니다.:
세분화된 토큰에는 다음 권한 집합이 있어야 합니다.:
- "Contents" repository permissions (read)
공용 리소스만 요청되는 경우 인증 또는 앞서 언급한 권한 없이 이 엔드포인트를 사용할 수 있습니다.
"Get a blob"에 대한 매개 변수
| 속성, 형식, 설명 | 
|---|
| acceptstringSetting to  | 
| 속성, 형식, 설명 | 
|---|
| ownerstring RequiredThe account owner of the repository. The name is not case sensitive. | 
| repostring RequiredThe name of the repository without the  | 
| file_shastring Required | 
"Get a blob"에 대한 HTTP 응답 상태 코드
| 상태 코드 | 설명 | 
|---|---|
| 200 | OK | 
| 403 | Forbidden | 
| 404 | Resource not found | 
| 409 | Conflict | 
| 422 | Validation failed, or the endpoint has been spammed. | 
"Get a blob"에 대한 코드 샘플
GHE.com에서 GitHub에 액세스하는 경우 api.github.com을 api.SUBDOMAIN.ghe.com의 엔터프라이즈 전용 하위 도메인으로 바꾸세요.
요청 예제
curl -L \
  -H "Accept: application/vnd.github+json" \
  -H "Authorization: Bearer <YOUR-TOKEN>" \
  -H "X-GitHub-Api-Version: 2022-11-28" \
  https://api.github.com/repos/OWNER/REPO/git/blobs/FILE_SHAResponse
Status: 200{
  "content": "Q29udGVudCBvZiB0aGUgYmxvYg==",
  "encoding": "base64",
  "url": "https://api.github.com/repos/octocat/example/git/blobs/3a0f86fb8db8eea7ccbb9a95f325ddbedfb25e15",
  "sha": "3a0f86fb8db8eea7ccbb9a95f325ddbedfb25e15",
  "size": 19,
  "node_id": "Q29udGVudCBvZiB0aGUgYmxvYg=="
}