Help us learn about your current experience with the documentation. Take the survey.
群组 Markdown 上传 API
- Tier: Free, Premium, Ultimate
- Offering: GitLab.com, GitLab Self-Managed, GitLab Dedicated
Markdown 上传是指上传到群组的文件,这些文件可以在史诗或维基页面的 Markdown 文本中被引用。
列出上传文件
获取群组的所有上传文件,并按 created_at(创建时间)降序排列。
您必须至少拥有维护者 (Maintainer) 角色才能使用此端点。
GET /groups/:id/uploads| 属性 | 类型 | 必需 | 描述 |
|---|---|---|---|
id |
integer 或 string | 是 | 群组的 ID 或 URL 编码路径。 |
示例请求:
curl --header "PRIVATE-TOKEN: <your_access_token>" "https://gitlab.example.com/api/v4/groups/5/uploads"示例响应:
[
{
"id": 1,
"size": 1024,
"filename": "image.png",
"created_at":"2024-06-20T15:53:03.067Z",
"uploaded_by": {
"id": 18,
"name" : "Alexandra Bashirian",
"username" : "eileen.lowe"
}
},
{
"id": 2,
"size": 512,
"filename": "other-image.png",
"created_at":"2024-06-19T15:53:03.067Z",
"uploaded_by": null
}
]通过 ID 下载已上传的文件
您必须至少拥有维护者 (Maintainer) 角色才能使用此端点。
GET /groups/:id/uploads/:upload_id支持的属性:
| 属性 | 类型 | 必需 | 描述 |
|---|---|---|---|
id |
integer 或 string | 是 | 群组的 ID 或 URL 编码路径。 |
upload_id |
integer | 是 | 上传文件的 ID。 |
示例请求:
curl --header "PRIVATE-TOKEN: <your_access_token>" "https://gitlab.example.com/api/v4/groups/5/uploads/1"如果成功,将返回 200 状态码,并在响应正文中包含已上传的文件。
通过密钥和文件名下载已上传的文件
您必须至少拥有访客 (Guest) 角色才能使用此端点。
GET /groups/:id/uploads/:secret/:filename支持的属性:
| 属性 | 类型 | 必需 | 描述 |
|---|---|---|---|
id |
integer 或 string | 是 | 群组的 ID 或 URL 编码路径。 |
secret |
string | 是 | 上传文件的 32 位字符密钥。 |
filename |
string | 是 | 上传文件的文件名。 |
示例请求:
curl --header "PRIVATE-TOKEN: <your_access_token>" "https://gitlab.example.com/api/v4/groups/5/uploads/648d97c6eef5fc5df8d1004565b3ee5a/sample.jpg"如果成功,将返回 200 状态码,并在响应正文中包含已上传的文件。
通过 ID 删除已上传的文件
您必须至少拥有维护者 (Maintainer) 角色才能使用此端点。
DELETE /groups/:id/uploads/:upload_id支持的属性:
| 属性 | 类型 | 必需 | 描述 |
|---|---|---|---|
id |
integer 或 string | 是 | 群组的 ID 或 URL 编码路径。 |
upload_id |
integer | 是 | 上传文件的 ID。 |
示例请求:
curl --request DELETE --header "PRIVATE-TOKEN: <your_access_token>" "https://gitlab.example.com/api/v4/groups/5/uploads/1"如果成功,将返回 204 状态码,且响应体为空。
通过密钥和文件名删除已上传的文件
您必须至少拥有维护者 (Maintainer) 角色才能使用此端点。
DELETE /groups/:id/uploads/:secret/:filename支持的属性:
| 属性 | 类型 | 必需 | 描述 |
|---|---|---|---|
id |
integer 或 string | 是 | 群组的 ID 或 URL 编码路径。 |
secret |
string | 是 | 上传文件的 32 位字符密钥。 |
filename |
string | 是 | 上传文件的文件名。 |
示例请求:
curl --request DELETE --header "PRIVATE-TOKEN: <your_access_token>" "https://gitlab.example.com/api/v4/groups/5/uploads/648d97c6eef5fc5df8d1004565b3ee5a/sample.jpg"如果成功,将返回 204 状态码,且响应体为空。