cURL
File upload consists of three steps:
- Apply for a lease (this API) — Obtain an OSS presigned URL and
leaseId - PUT upload to OSS — Upload the file’s binary content via HTTP PUT using the returned
param.urlandparam.headers - Register the file (addFile) — Register the file in the data center using the
leaseId
Complete Upload Example
Authorizations
string
header
required
DashScope API Key,在控制台 API Key 页面 获取。
Body
application/jsonstring
required
类目 ID(注意:此字段名为 category,不是 categoryId),通过 listCategory 获取。
string
required
文件名称,包含扩展名。
string
required
文件大小(字节),以字符串格式传入。
x >= 1
string
required
文件内容的 MD5 值(Base64 编码)。
length: 1–64
enum<string>
default"UNSTRUCTURED"
类目类型,默认 UNSTRUCTURED。UNSTRUCTURED:类目,用于构建知识库;SESSION_FILE:用于智能体应用会话交互的文件。使用 SESSION_FILE 时,addFile 的 categoryType 也须传 SESSION_FILE;此类文件仅当前会话有效,关闭会话后过期(最长 7 天),不支持长期保存。
UNSTRUCTURED,SESSION_FILE
boolean
defaultfalse
是否使用安全存储空间的内网 Endpoint 上传,默认 false。