文档API 参考

Rust · 0.1.0

Upload Attachment

POST /api/v1/attachments:upload

AttachmentService · AttachmentService_UploadAttachment

基于协议生成的参考。授权与实例策略仍然生效。结构描述继承自 MIT 许可的应用接口定义;本站不会向真实服务执行示例。

访问权限

需要有效账号认证;实例策略及下方操作特有的检查仍然适用。

分块上传流程

开始时提供 spec.attachment 元数据、spec.totalSize 和 writeOffset "0"。文件字节放在 data,而非 spec.attachment.content;REST 中 data 使用 Base64。之后使用返回的 uploadId,并把 committedSize 作为 writeOffset。每块解码后不得超过 maxChunkSize(当前 2 MiB)。所有字节提交后再设置 finishWrite: true。无数据且不结束的调用可查询进度;支持以相同字节重放最近一块。会话属于调用者,闲置 30 分钟过期,重启后丢失。完成后保存附件 name,而非 uploadId。

请求

UploadAttachment uploads a file in bounded chunks. The first call carries the spec and returns an upload_id; later calls carry that upload_id. Uploads are bound to the authenticated user, expire after 30 minutes of inactivity, and do not survive a server restart.

POST/api/v1/attachments:upload

参数

未声明路径或查询参数。

请求体

必需

application/json · UploadAttachmentRequest

响应

200 · OK

application/json · UploadAttachmentResponse

default · Default error response

application/json · Status

完整操作定义

下方保留全部已声明约束、媒体类型和响应细节。结构引用链接到完整定义。

展开 JSON 定义
{
  "tags": [
    "AttachmentService"
  ],
  "description": "UploadAttachment uploads a file in bounded chunks. The first call carries\n the spec and returns an upload_id; later calls carry that upload_id.\n Uploads are bound to the authenticated user, expire after 30 minutes of\n inactivity, and do not survive a server restart.",
  "operationId": "AttachmentService_UploadAttachment",
  "requestBody": {
    "content": {
      "application/json": {
        "schema": {
          "$ref": "#/components/schemas/UploadAttachmentRequest"
        }
      }
    },
    "required": true
  },
  "responses": {
    "200": {
      "description": "OK",
      "content": {
        "application/json": {
          "schema": {
            "$ref": "#/components/schemas/UploadAttachmentResponse"
          }
        }
      }
    },
    "default": {
      "description": "Default error response",
      "content": {
        "application/json": {
          "schema": {
            "$ref": "#/components/schemas/Status"
          }
        }
      }
    }
  }
}