Help us learn about your current experience with the documentation. Take the survey.
项目级安全文件 API
- 等级:免费版、高级版、旗舰版
- 提供方式:GitLab.com、GitLab 自托管、GitLab 专用版
使用此 API 管理项目的 安全文件。
列出项目安全文件
获取项目中的安全文件列表。
GET /projects/:project_id/secure_files支持的参数:
| 参数 | 类型 | 必需 | 描述 |
|---|---|---|---|
project_id |
integer/string | 是 | 项目的 ID 或 URL 编码的路径。 |
示例请求:
curl --header "PRIVATE-TOKEN: <your_access_token>" \
--url "https://gitlab.example.com/api/v4/projects/1/secure_files"示例响应:
[
{
"id": 1,
"name": "myfile.jks",
"checksum": "16630b189ab34b2e3504f4758e1054d2e478deda510b2b08cc0ef38d12e80aac",
"checksum_algorithm": "sha256",
"created_at": "2022-02-22T22:22:22.222Z",
"expires_at": null,
"metadata": null
},
{
"id": 2,
"name": "myfile.cer",
"checksum": "16630b189ab34b2e3504f4758e1054d2e478deda510b2b08cc0ef38d12e80aa2",
"checksum_algorithm": "sha256",
"created_at": "2022-02-22T22:22:22.222Z",
"expires_at": "2023-09-21T14:55:59.000Z",
"metadata": {
"id":"75949910542696343243264405377658443914",
"issuer": {
"C":"US",
"O":"Apple Inc.",
"CN":"Apple Worldwide Developer Relations Certification Authority",
"OU":"G3"
},
"subject": {
"C":"US",
"O":"Organization Name",
"CN":"Apple Distribution: Organization Name (ABC123XYZ)",
"OU":"ABC123XYZ",
"UID":"ABC123XYZ"
},
"expires_at":"2023-09-21T14:55:59.000Z"
}
}
]显示安全文件详情
获取项目中特定安全文件的详情。
GET /projects/:project_id/secure_files/:id支持的参数:
| 参数 | 类型 | 必需 | 描述 |
|---|---|---|---|
id |
integer | 是 | 安全文件的 ID。 |
project_id |
integer/string | 是 | 项目的 ID 或 URL 编码的路径。 |
示例请求:
curl --header "PRIVATE-TOKEN: <your_access_token>" \
--url "https://gitlab.example.com/api/v4/projects/1/secure_files/1"示例响应:
{
"id": 1,
"name": "myfile.jks",
"checksum": "16630b189ab34b2e3504f4758e1054d2e478deda510b2b08cc0ef38d12e80aac",
"checksum_algorithm": "sha256",
"created_at": "2022-02-22T22:22:22.222Z",
"expires_at": null,
"metadata": null
}创建安全文件
创建一个新的安全文件。
POST /projects/:project_id/secure_files支持的参数:
| 参数 | 类型 | 必需 | 描述 |
|---|---|---|---|
file |
file | 是 | 要上传的文件(限制 5 MB)。 |
name |
string | 是 | 要上传的文件名。文件名在项目中必须唯一。 |
project_id |
integer/string | 是 | 项目的 ID 或 URL 编码的路径。 |
示例请求:
curl --request POST \
--header "PRIVATE-TOKEN: <your_access_token>" \
--url "https://gitlab.example.com/api/v4/projects/1/secure_files" \
--form "name=myfile.jks" \
--form "file=@/path/to/file/myfile.jks"示例响应:
{
"id": 1,
"name": "myfile.jks",
"checksum": "16630b189ab34b2e3504f4758e1054d2e478deda510b2b08cc0ef38d12e80aac",
"checksum_algorithm": "sha256",
"created_at": "2022-02-22T22:22:22.222Z",
"expires_at": null,
"metadata": null
}下载安全文件
下载项目安全文件的内容。
GET /projects/:project_id/secure_files/:id/download支持的参数:
| 参数 | 类型 | 必需 | 描述 |
|---|---|---|---|
id |
integer | 是 | 安全文件的 ID。 |
project_id |
integer/string | 是 | 项目的 ID 或 URL 编码的路径。 |
示例请求:
curl --request GET \
--header "PRIVATE-TOKEN: <your_access_token>" \
--url "https://gitlab.example.com/api/v4/projects/1/secure_files/1/download" \
--output myfile.jks删除安全文件
删除项目的安全文件。
DELETE /projects/:project_id/secure_files/:id支持的参数:
| 参数 | 类型 | 必需 | 描述 |
|---|---|---|---|
id |
integer | 是 | 安全文件的 ID。 |
project_id |
integer/string | 是 | 项目的 ID 或 URL 编码的路径。 |
示例请求:
curl --request DELETE \
--header "PRIVATE-TOKEN: <your_access_token>" \
--url "https://gitlab.example.com/api/v4/projects/1/secure_files/1"