分页列出工作空间下的文件,按 created_at 倒序返回。可通过 scope_id 仅列出某会话沙箱内的文件。
前提
已完成 Endpoint 与鉴权配置,详见API 总览与认证。
接口
GET
/files查询参数
limitint默认 20每页数量,最大 100
pagestring默认 —首次不传,后续传上一次响应的 next_page
scope_idstring默认 —传入会话 ID,仅返回该会话沙箱内的文件
请求示例
curl "$AGENTSTUDIO_URL/files?limit=20" \
-H "Authorization: Bearer $DASHSCOPE_API_KEY"
import os
import dashscope
client = dashscope.Client(api_key=os.getenv('DASHSCOPE_API_KEY'))
# 列出已上传的文件(page_no 为页码,page_size 为每页数量)
result = client.files.list(page_no=1, page_size=10)
print(result.files)
CursorPage<AgentStudioFile> page = client.files().list(
FileListParam.builder().limit(20).build());
for (AgentStudioFile f : page.getData()) {
System.out.println(f.getId() + " " + f.getFilename() + " " + f.getSizeBytes());
}
响应示例
{
"data": [
{
"id": "file_xxx",
"type": "file",
"filename": "sales_2025.csv",
"downloadable": false,
"mime_type": "text/csv",
"size_bytes": 524288,
"status": "available",
"created_at": "2026-06-16T14:51:39+08:00"
},
{
"id": "file_xxx",
"type": "file",
"filename": "demo.png",
"downloadable": false,
"mime_type": "image/png",
"size_bytes": 102400,
"status": "checking",
"created_at": "2026-06-16T14:48:02+08:00"
}
],
"next_page": "xxx",
"requestId": "xxx"
}
响应包含 data(File 对象数组)与 next_page。File 对象字段如下:
响应字段
dataarray<File>File 对象数组
data[] File 对象字段
idstring文件 ID,格式 file_<24位字母数字>
typestring固定为 file
filenamestring文件名
mime_typestring服务端检测的 MIME 类型
size_bytesint文件大小,单位字节
downloadablebool是否支持下载,当前接口直传与会话沙箱拷贝均为 false
statusstring安全审核状态:available / checking / rejected / type_rejected
created_atstring上传时间,ISO 8601
next_pagestring / null下一页游标;无更多数据时不返回或为 null
requestIdstring本次请求的唯一标识
该文章对您有帮助吗?