GetAgentCodePackageUploadUrl - 获取智能体代码包上传地址
获取智能体代码包上传地址
接口说明
获取代码包限时上传地址,不上传文件内容。fileName 必须为不含目录的 ZIP 或 TAR.GZ 文件名,format 须与扩展名一致,fileSize 为字节数,取值 1~500000000。
使用响应的 uploadMethod、uploadUrl 和 headers 直接上传文件;上传完成后,将 sourceUri 传给 CreateCustomAgent 或 UpdateCustomAgent 的 artifact.code.sourceUri。创建或更新时还会检查实际对象和大小并保存固定副本。上传链接有效期最长 10 分钟,且不超过底层临时凭证期限;过期后重新获取。示例链接已脱敏,不可用于实际上传,请使用本次响应的原始链接及请求头。
调试
您可以在OpenAPI Explorer中直接运行该接口,免去您计算签名的困扰。运行成功后,OpenAPI Explorer可以自动生成SDK代码示例。
调试
授权信息
|
操作 |
访问级别 |
资源类型 |
条件关键字 |
关联操作 |
|
agentcore:GetAgentCodePackageUploadUrl |
none |
*Workspace
|
无 | 无 |
请求语法
POST /workspaces/{workspaceId}/agent-code-packages/upload-url HTTP/1.1
路径参数
|
名称 |
类型 |
必填 |
描述 |
示例值 |
| workspaceId |
string |
是 |
工作空间 ID |
ws-a1b2c3d4e5f6 |
请求参数
|
名称 |
类型 |
必填 |
描述 |
示例值 |
| body |
object |
是 |
请求体 |
|
| fileName |
string |
是 |
代码包文件名 |
main.zip |
| fileSize |
integer |
是 |
声明代码包压缩大小 |
123 |
| format |
string |
是 |
代码包格式 枚举值:
|
zip |
返回参数
|
名称 |
类型 |
描述 |
示例值 |
|
object |
|||
| requestId |
string |
请求 ID |
550e8400-e29b-41d4-a716-446655440000 |
| message |
string |
响应消息 |
success |
| httpStatusCode |
integer |
HTTP 状态码 |
200 |
| code |
string |
业务状态码 |
SUCCESS |
| success |
boolean |
请求是否成功 |
|
| data |
object |
返回结果 |
|
| sourceUri |
string |
临时代码包 OSS URI |
oss://agentcore-platform-example/code-package-uploads/workspaces/ws-a1b2c3d4e5f6/550e8400-e29b-41d4-a716-446655440000/package.zip |
| uploadMethod |
string |
直传 HTTP 方法 |
PUT |
| uploadUrl |
string |
限时预签名上传地址 |
https://agentcore-platform-example.oss-cn-hangzhou.aliyuncs.com/code-package-uploads/workspaces/ws-a1b2c3d4e5f6/550e8400-e29b-41d4-a716-446655440000/package.zip?OSSAccessKeyId=LTAI5tExample****&Expires=1792627800&Signature=ExampleSignature**** |
| headers |
object |
直传时必须携带的 HTTP 请求头 |
|
|
string |
上传请求头的字符串值;按接口返回的原值发送,例如 Content-Type 对应 application/zip。 |
application/zip |
|
| expiresAt |
string |
上传地址过期时间 |
2026-10-22T00:10:00Z |
| maxSize |
integer |
代码包压缩大小上限 |
500000000 |
示例
正常返回示例
JSON格式
{
"requestId": "550e8400-e29b-41d4-a716-446655440000",
"message": "success",
"httpStatusCode": 200,
"code": "SUCCESS",
"success": true,
"data": {
"sourceUri": "oss://agentcore-platform-example/code-package-uploads/workspaces/ws-a1b2c3d4e5f6/550e8400-e29b-41d4-a716-446655440000/package.zip",
"uploadMethod": "PUT",
"uploadUrl": "https://agentcore-platform-example.oss-cn-hangzhou.aliyuncs.com/code-package-uploads/workspaces/ws-a1b2c3d4e5f6/550e8400-e29b-41d4-a716-446655440000/package.zip?OSSAccessKeyId=LTAI5tExample****&Expires=1792627800&Signature=ExampleSignature****",
"headers": {
"key": "application/zip"
},
"expiresAt": "2026-10-22T00:10:00Z",
"maxSize": 500000000
}
}
错误码
|
HTTP status code |
错误码 |
错误信息 |
描述 |
|---|---|---|---|
| 400 | InvalidParameter | A code package request parameter is invalid. | |
| 400 | AgentCodePackage.Invalid | The code package source or format is invalid. | |
| 403 | Forbidden | The caller is not allowed to access the specified workspace or agent. | |
| 404 | Resource.NotFound | The specified workspace does not exist. | |
| 503 | AgentCodePackage.StorageUnavailable | The platform code package storage is unavailable. | |
| 409 | Workspace.Operation.Conflict | The workspace cannot accept this operation in its current state. |
访问错误中心查看更多错误码。
变更历史
更多信息,参考变更详情。