文件收发
你需要先了解鉴权
章节
文件收发使用独立接口,收发接口通过upload_token
和download_token
鉴权,遵循以下要求
- 两种token由其他接口生成,生成token时服务端已得知待传输文件的名称大小等信息,服务端能够通过token得知这些信息
- 两种token有效期不应过长,
upload_token
在上传成功后立即失效,download_token
不限制下载次数 - 在上传时,上传接口能够根据token信息调用相应的接口实现服务端的自定义逻辑
上传
sequenceDiagram
participant C as Client
participant F as FunctionInterface
participant T as TransferInterface
C->>+F: require to upload file
F->>F: check request
F->>-C: accept with `upload_token`
C->>+T: start upload file
T->>T: check token
loop
C-->>T: file bytes
T-->>C: bytes recieved
end
T->>T: check file
T-->>+F: file recieved, do the rest
F-->>-T: done
T->>-C: upload success
下载
sequenceDiagram
participant C as Client
participant F as FunctionInterface
participant T as TransferInterface
C->>+F: require to download file
F->>F: check request
F->>-C: accept with `download_token`
C->>+T: start download file
T->>T: check token
loop
T-->>C: file bytes
opt advanced transfer
C-->>T: require exact chunk
end
end
T->>-C: download finish