下载仓库release附件¶
GET /api/v5/repos/{owner}/{repo}/releases/{tag}/attach_files/{file_name}/download
用户调用此接口,下载仓库 release 附件。
访问令牌支持说明¶
- AtomGit 用户访问令牌(AtomGit user access tokens)
是否允许匿名访问¶
此接口允许匿名访问
请求参数¶
| 参数名 | 位置 | 类型 | 必填 | 说明 |
|---|---|---|---|---|
owner |
path | string | 是 | 仓库所属空间地址(企业、组织或个人的地址path) |
repo |
path | string | 是 | 仓库路径(path) |
tag |
path | string | 是 | 标签名称 |
file_name |
path | string | 是 | 附件名称 |
响应参数¶
成功时直接返回附件文件的二进制内容(文件流),无结构化响应字段。
失败响应¶
接口的失败响应遵循平台统一的错误格式,错误字段名以后端实际返回为准。可能发生的失败场景包括:
401 未认证
携带的访问令牌无效或缺失时返回。
404 资源不存在
release 或附件不存在时返回。
HTTP 响应状态码¶
| 状态码 | 说明 |
|---|---|
200 |
成功(OK) |
401 |
需要认证(Requires authentication) |
404 |
资源不存在(Not found) |
429 |
请求过于频繁,触发限流 |
500 |
系统内部错误 |
请求示例¶
参数说明¶
此接口允许匿名访问,调用时无需携带访问令牌;如需以用户身份访问,也可携带 access_token 查询参数。
<owner>替换为仓库所属空间地址(企业、组织或个人的地址 path);<repo>替换为仓库路径(path);<tag>替换为 release 标签名称;<file_name>替换为附件名称。
cURL¶
curl -L -X GET 'https://api.atomgit.com/api/v5/repos/<owner>/<repo>/releases/<tag>/attach_files/<file_name>/download'
JavaScript¶
// 原生 fetch (Node.js 18+ / 浏览器)
const response = await fetch("https://api.atomgit.com/api/v5/repos/<owner>/<repo>/releases/<tag>/attach_files/<file_name>/download", {
headers: {
"Accept": "*/*",
},
});
if (!response.ok) {
throw new Error(`请求失败: ${response.status}`);
}
const blob = await response.blob();
console.log(blob);
Python¶
import requests
resp = requests.get(
"https://api.atomgit.com/api/v5/repos/<owner>/<repo>/releases/<tag>/attach_files/<file_name>/download",
timeout=10,
)
resp.raise_for_status()
print(resp.content)
响应示例¶
状态码: 200
成功时返回附件文件的二进制内容(响应体为文件流,无结构化字段)。
错误码¶
| 错误码 | 说明 |
|---|---|
401 |
未认证或凭证无效(缺少/无效的访问凭证) |
404 |
资源不存在(release 或附件不存在) |
429 |
请求过于频繁,触发限流 |
500 |
系统内部错误 |
本页原文 Markdown:在 AtomGit 查看·内容源自开源项目 gitcode-dev/atomgit-api-doc