POST /api/v1/projects/{projectId}/files/presign
POST
/api/v1/projects/{projectId}/files/presign生成文件下载签名 URL(需 developer 及以上;key 必须属于本项目且已通过审核)
请求参数
| 名称 | 类型 | 位置 | 必填 | 说明 |
|---|---|---|---|---|
projectId | string | path | 是 | 项目 ID(UUID)。携带 `X-API-Key` 时按 API Key scope 鉴权,否则按 JWT + 项目成员角色鉴权 |
请求体
请求数据
Content-Type · application/json
{
"type": "object",
"required": [
"key"
],
"properties": {
"key": {
"type": "string",
"description": "必须以 `<项目slug>/` 开头"
}
}
}请求示例
cURL
curl -X POST 'http://localhost:8080/api/v1/projects/{projectId}/files/presign' \
-H 'Accept: application/json' \
-H 'X-API-Key: <PROJECT_API_KEY>'
# 也可使用登录会话:-H 'Authorization: Bearer <JWT>'JavaScript
const res = await fetch('http://localhost:8080/api/v1/projects/{projectId}/files/presign', {
method: 'POST',
headers: {
'Accept': 'application/json',
'X-API-Key': '<PROJECT_API_KEY>'
},
});
const data = await res.json();Python
import requests
res = requests.post(
'http://localhost:8080/api/v1/projects/{projectId}/files/presign',
headers={'Accept': 'application/json', 'X-API-Key': '<PROJECT_API_KEY>'}
)
print(res.json())响应
200签名 URL(默认 5 分钟有效)
application/json
{
"type": "object",
"properties": {
"url": {
"type": "string"
},
"method": {
"type": "string"
},
"headers": {
"type": "object",
"additionalProperties": {
"type": "string"
}
},
"expires_at": {
"type": "string",
"format": "date-time"
}
}
}400请求参数错误
application/json
{
"type": "object",
"properties": {
"code": {
"type": "string",
"example": "not_found"
},
"message": {
"type": "string",
"example": "资源不存在"
}
}
}403对象不存在或尚未通过审核
在线调试
在线调试
凭证仅保存在当前页面内存中自定义请求 Header
