跳到导航

多部分文件上传

以 Markdown 格式查看

Fern 中的端点定义在 endpoints 键下。如果您的端点请求包含文件上传,您可以使用 file 类型来指示请求是 multiform 内容类型。下面的示例演示了一个在请求体中包含文件的端点。

document.yml
service:
base-path: /documents
auth: false
endpoints:
uploadDocument:
path: /upload
method: POST
request:
name: UploadDocumentRequest
body:
properties:
file: file

在给定的多部分请求中,带有 format:binary 的字符串参数将表示任意文件。

文件列表

如果您的端点支持文件列表,那么您的请求体必须指明这一点。

document.yml
service:
base-path: /documents
auth: false
endpoints:
uploadDocuments:
path: /upload
method: POST
request:
name: UploadDocumentsRequest
body:
properties:
files: list<file>