Forward File API 复用的响应结构。
File 对象
上传、查询、列表接口都会返回该结构。
| 字段 | 类型 | 说明 |
|---|---|---|
id | string | File ID,前缀为 file_ |
type | string | 固定值 "file" |
filename | string | 存储后的文件名 |
size_bytes | integer | 文件大小,单位 byte |
mime_type | string | 上传时提供或根据文件名检测的 MIME type |
downloadable | boolean | 是否可通过 /content 端点下载 |
scope | object | null | 文件关联到其他资源时的 scope,例如 { "id": "sess_...", "type": "session" };未挂载时为 null |
metadata | object | 上传时传入的自定义元数据对象;省略时为 {}。created_by 为 Forward 保留字段,调用方不可传入 |
identity_id | string | null | Forward 归属身份;PAT 创建时通常为 null |
icon_url | string | null | Forward 关联的 icon URL |
binding_info | Binding info | 绑定信息(Template 引用计数等) |
created_at | string | 创建时间,RFC 3339 格式 |
updated_at | string | 最后更新时间,RFC 3339 格式 |
支持上传的文件类型
上传接口只接受文本类文件。
| 类别 | 支持的值 |
|---|---|
| MIME type | 任意 text/* MIME type,以及 application/json、application/xml、application/javascript、application/x-yaml、application/x-toml |
| 文件扩展名 | .txt、.md、.csv、.json、.xml、.yaml、.yml、.toml、.ini、.conf、.cfg、.env、.log、.html、.htm、.css、.scss、.less、.js、.jsx、.ts、.tsx、.vue、.svelte、.py、.go、.rs、.java、.kt、.scala、.c、.cpp、.cc、.h、.hpp、.rb、.php、.swift、.r、.lua、.pl、.sh、.bash、.zsh、.fish、.ps1、.sql、.graphql、.gql、.proto、.dockerfile、.makefile、.gitignore、.editorconfig、.eslintrc、.prettierrc、.tex、.rst、.adoc、.org、.svg |
| 无扩展名文件名 | dockerfile、makefile、gemfile、rakefile、procfile、vagrantfile、justfile、brewfile |
File 下载响应对象
下载 File 接口返回该结构,包含短期有效的预签名 URL。
| 字段 | 类型 | 说明 |
|---|---|---|
url | string | 预签名下载 URL |
expires_at | string | URL 过期时间,RFC 3339 格式 |
filename | string | 建议的下载文件名(用于浏览器 Content-Disposition) |
Binding info
Forward 在 File 响应中携带的引用聚合。
| 字段 | 类型 | 说明 |
|---|---|---|
agent_template_count | integer | 当前绑定该 File 的 Template 数量 |
列表分页字段
| 字段 | 类型 | 说明 |
|---|---|---|
data | File 对象 数组 | 当前页记录 |
has_more | boolean | 是否还有下一页 |
next_page | string | null | 下一页向后游标(推荐使用);has_more=true 时等于当前页 last_id,否则为 null |
first_id | string | null | 当前页第一条记录 ID |
last_id | string | null | 当前页最后一条记录 ID |
page / after_id / before_id 互斥,同时提供多个返回 400;推荐使用 page,语义等价于 after_id。