Skip to main content
이제 REST API의 버전이 지정되었습니다. 자세한 내용은 "API 버전 관리 정보"를 참조하세요.

Git 미확인 개체에 대한 REST API 엔드포인트

각 파일의 콘텐츠를 리포지토리에 저장하는 데 사용되는 개체 형식인 Git BLOB(Binary Large Object)와 상호 작용하려면 REST API를 사용하십시오.

Git Blob 정보

Git BLOB(Binary Large Object)은 각 파일의 콘텐츠를 리포지토리에 저장하는 데 사용되는 개체 형식입니다. 파일의 SHA-1 해시는 계산되어 BLOB 개체에 저장됩니다. 엔드포인트를 사용하면 GitHub Enterprise Cloud에서 Git 데이터베이스에 BLOB 개체를 읽고 쓸 수 있습니다. BLOB은 사용자 지정 미디어 유형을 활용합니다. API에서 미디어 형식을 사용하는 방법에 대한 자세한 정보는 "AUTOTITLE"을(를) 참조하세요.

Create a blob

"Create a blob"에 대한 세분화된 액세스 토큰

이 엔드포인트는 다음 토큰 형식에서 작동합니다.:

토큰에 다음 권한 집합이 있어야 합니다.:

  • contents:write

"Create a blob"에 대한 매개 변수

헤더
이름, Type, 설명
accept string

Setting to application/vnd.github+json is recommended.

경로 매개 변수
이름, Type, 설명
owner string Required

The account owner of the repository. The name is not case sensitive.

repo string Required

The name of the repository without the .git extension. The name is not case sensitive.

본문 매개 변수
이름, Type, 설명
content string Required

The new blob's content.

encoding string

The encoding used for content. Currently, "utf-8" and "base64" are supported.

기본값: utf-8

"Create a blob"에 대한 HTTP 응답 상태 코드

상태 코드설명
201

Created

403

Forbidden

404

Resource not found

409

Conflict

422

Validation failed, or the endpoint has been spammed.

"Create a blob"에 대한 코드 샘플

요청 예제

post/repos/{owner}/{repo}/git/blobs
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 content as 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:read

공용 리소스만 요청되는 경우 인증 또는 앞서 언급한 권한 없이 이 엔드포인트를 사용할 수 있습니다.

"Get a blob"에 대한 매개 변수

헤더
이름, Type, 설명
accept string

Setting to application/vnd.github+json is recommended.

경로 매개 변수
이름, Type, 설명
owner string Required

The account owner of the repository. The name is not case sensitive.

repo string Required

The name of the repository without the .git extension. The name is not case sensitive.

file_sha string 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"에 대한 코드 샘플

요청 예제

get/repos/{owner}/{repo}/git/blobs/{file_sha}
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_SHA

Response

Status: 200
{ "content": "Q29udGVudCBvZiB0aGUgYmxvYg==", "encoding": "base64", "url": "https://api.github.com/repos/octocat/example/git/blobs/3a0f86fb8db8eea7ccbb9a95f325ddbedfb25e15", "sha": "3a0f86fb8db8eea7ccbb9a95f325ddbedfb25e15", "size": 19, "node_id": "Q29udGVudCBvZiB0aGUgYmxvYg==" }