このバージョンの GitHub Enterprise はこの日付をもって終了となりました: 2022-10-12. 重大なセキュリティの問題に対してであっても、パッチリリースは作成されません。 パフォーマンスの向上、セキュリティの向上、新機能の向上を図るために、最新バージョンの GitHub Enterprise にアップグレードします。 アップグレードに関するヘルプについては、GitHub Enterprise サポートにお問い合わせく� さい。
Git BLOB
Git BLOB API を使うと、リポジトリ内の各ファイルのコンテンツを� �納するために使われるオブジェクトの種類である Git BLOB (バイナリ ラージ オブジェクト) を作成し、取得することができます。
Git BLOB API について
Git blob (バイナリラージオブジェクト) は、各ファイルのコンテンツをリポジトリに保存する際に使用されるオブジェクトタイプです。 ファイルの SHA-1 ハッシュが計算され、blob オブジェクトに保存されます。 これらのエンドポイントを使うと、GitHub Enterprise Server 上の Git データベースの BLOB オブジェクトを読み書きできます。 BLOB では、これらのカスタ� メディアの種類が利用されます。 API でのメディア タイプの使用に関する詳細については、こちらをお読みく� さい。
Blob のカスタ� メディアタイプ
これらは、blob でサポートされているメディアタイプです。
application/json application/vnd.github.VERSION.raw 詳細については、「メディア タイプ」を参照してく� さい。
Create a blob
パラメーター
| Headers |
|---|
| Name, Type, Description |
acceptstringSetting to |
| Path parameters |
| Name, Type, Description |
ownerstringRequiredThe account owner of the repository. The name is not case sensitive. |
repostringRequiredThe name of the repository. The name is not case sensitive. |
| Body parameters |
| Name, Type, Description |
contentstringRequiredThe new blob's content. |
encodingstringThe encoding used for Default: |
HTTP 応答状態コード
| status code | 説明 |
|---|---|
201 | Created |
403 | Forbidden |
404 | Resource not found |
409 | Conflict |
422 | Validation failed, or the endpoint has been spammed. |
コード サンプル
curl \ -X POST \ -H "Accept: application/vnd.github+json" \ -H "Authorization: Bearer <YOUR-TOKEN>" \ http(s)://HOSTNAME/api/v3/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.
Note: This API supports blobs up to 100 megabytes in size.
パラメーター
| Headers |
|---|
| Name, Type, Description |
acceptstringSetting to |
| Path parameters |
| Name, Type, Description |
ownerstringRequiredThe account owner of the repository. The name is not case sensitive. |
repostringRequiredThe name of the repository. The name is not case sensitive. |
file_shastringRequired |
HTTP 応答状態コード
| status code | 説明 |
|---|---|
200 | OK |
403 | Forbidden |
404 | Resource not found |
422 | Validation failed, or the endpoint has been spammed. |
コード サンプル
curl \ -H "Accept: application/vnd.github+json" \ -H "Authorization: Bearer <YOUR-TOKEN>" \ http(s)://HOSTNAME/api/v3/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==" }