1. 上传
Cloudreve API Docs
  • README
  • 站点信息
    • 健康检查
      GET
    • 获取验证码
      GET
    • 获取站点设置
      GET
    • 举报滥用
      POST
  • 会话管理
    • 令牌
      • 密码登录
      • 完成双因素认证登录
      • 刷新令牌
      • 退出登录
    • 开放ID
      • 准备OpenID登录
      • 完成OpenID登录
      • 解绑OpenID
    • 通行密钥
      • 准备通行密钥登录
      • 完成通行密钥登录
    • 准备登录
  • 用户管理
    • 通行密钥
      • 准备通行密钥注册
      • 完成通行密钥注册
      • 删除通行密钥
    • 设置
      • 列出可用存储策略
      • 列出可用节点
      • 获取偏好设置
      • 准备启用双因素认证
      • 更新偏好设置
      • 更新头像
    • 用户注册
    • 发送密码重置邮件
    • 通过临时链接重置密码
    • 获取头像
    • 获取用户信息
    • 列出用户的分享链接
    • 获取存储容量
    • 搜索用户
    • 列出积分变更记录
    • 列出支付记录
  • 回调
    • 完成OBS上传
    • 完成OneDrive上传
    • 完成COS上传
    • 完成S3上传
  • 工作流
    • 远程下载
      • 创建远程下载
      • 选择要下载的文件
      • 取消任务
    • 列出任务
    • 获取任务进度
    • 创建压缩包
    • 提取压缩包
    • 重新定位存储策略
    • 导入外部文件
  • 文件管理
    • 权限管理
      • 设置权限
      • 删除权限设置
    • 上传
      • 创建上传会话
        PUT
      • 上传文件分块
        POST
      • 删除上传会话
        DELETE
    • 固定项
      • 固定到侧边栏
      • 删除固定项
    • 版本管理
      • 设置文件版本
      • 删除文件版本
    • 直链管理
      • 创建直链
      • 删除直链
    • 列出文件
      GET
    • 列出文件活动
      GET
    • 获取文件信息
      GET
    • 获取缩略图URL
      GET
    • 获取压缩包文件列表
      GET
    • 更新文件内容
      PUT
    • 创建查看器会话
      PUT
    • 创建文件
      POST
    • 重命名文件
      POST
    • 移动或复制文件
      POST
    • 创建下载URL
      POST
    • 从回收站恢复
      POST
    • 删除文件
      DELETE
    • 强制解锁
      DELETE
    • 修补元数据
      PATCH
    • 挂载存储策略
      PATCH
    • 更新视图设置
      PATCH
  • 分享管理
    • 创建分享链接
    • 编辑分享链接
    • 获取分享链接信息
    • 列出我的分享链接
    • 删除分享链接
  • VAS
    • 支付
      • 创建支付
      • 获取支付状态
    • 礼品码
      • 检查礼品码
      • 兑换礼品码
  • 用户组
    • 列出用户组
  • WebDAV账号
    • 列出账号
    • 创建账号
    • 更新账号
    • 删除账号
  • 数据模型
    • Response
    • SiteConfig
    • User
    • Group
    • FileViewer
    • PaymentProvider
    • PaymentSetting
    • StorageProduct
    • GroupSKU
    • CaptchaFields
    • Token
    • LoginResponse
    • PermissionSetting
    • Share
    • PaginationResults
    • ListShareResponse
    • TaskListResponse
    • Node
    • TaskResponse
    • Progress
    • ArchiveWorkflowService
    • StoragePolicy
    • Entity
    • ExtendedInfo
    • FolderSummary
    • FileResponse
    • NavigatorProps
    • ListResponse
    • LogEntry
    • Activity
    • FileActivitiesResponse
    • ExplorerView
    • ListViewColumn
    • PinFileService
    • ShareCreateService
    • Payment
    • Passkey
    • DavAccount
    • CreateDavAccountService
    • CustomProps
    • CustomNavItem
    • CustomHTML
    • ArchivedFile
  1. 上传

创建上传会话

PUT
/file/upload
Create a upload session, which is required before uploading files. After upload session created, client should start uploading using the information included in the upload session. The implementation of upload differs from different storage policy type, you can find Cloudreve's implentation in uploader.
A general file uploading includes 3 steps: Create upload session, upload chunks, finish upload request. For small files, please consider using Update file content.

1. Create upload session#

Use current method to create an upload session.

2. Upload chunks#

For local storage policy, or any other storage policy with storage_policy.relay set to true, use Upload file chunk;
For remote storage policy, send chunks to the URL defined in upload_urls, there should be only one element in upload_urls. The request is similar to Upload file chunk, except:
Chunk index is passed through query chunk, e.g. http://slavecloudreve.com:5213/api/v4/slave/upload/f1dd2c8c-0c51-475b-a086-b338ae1d8109?chunk=2
Authorization shoud be the value of credential in upload session, e.g. Bearer Cr sBnnQ3rZ-UBr7d8ohKpUFtsQc8OMLuWwn1VhuJtdc5k=:1749623351
For any other storage policies, please refer to:
S3: UploadPart
OSS: UploadPart
COS: UploadPart
OBS: Uploading Parts
OneDrive: Upload bytes to the upload session
Qiniu: 分块上传数据
Upyun: 大文件上传

3. Finish upload#

For local/remote/upyun storage policy, or any other storage policy with storage_policy.relay set to true, you don't need to finish upload, it's automatically finished after last chunk uploaded.
OneDrive: Complete OneDrive upload
S3: CompleteMultipartUpload, then send Complete S3 upload
COS: Complete Multipart Upload, then send Complete COS upload
OBS: Completing a Multipart Upload, then send Complete OBS upload
Qiniu: 完成文件上传

请求参数

Authorization
在 Header 添加参数
Authorization
,其值为在 Bearer 之后拼接 Token
示例:
Authorization: Bearer ********************
Header 参数

Body 参数application/json

示例

返回响应

🟢200Success
application/json
Bodyapplication/json

请求示例请求示例
Shell
JavaScript
Java
Swift
curl --location --request PUT '/file/upload' \
--header 'X-Cr-Purchase-Ticket: 1f63aa26-edc0-40ce-950a-cb4d4323158e' \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '{
    "uri": "cloudreve://my/Inspirations/archive%20(3).zip",
    "size": 65328441,
    "policy_id": "J7uV",
    "last_modified": 1749524701494,
    "mime_type": "application/zip"
}'
响应示例响应示例
{
    "code": 0,
    "data": {
        "session_id": "9897ebae-7b73-4169-aabc-6396f470e4bb",
        "upload_id": "",
        "chunk_size": 26214400,
        "expires": 1749620196,
        "storage_policy": {
            "id": "J7uV",
            "name": "Default storage policy",
            "type": "local",
            "max_size": 0
        },
        "uri": "cloudreve://my/Inspirations/archive%20(3).zip",
        "callback_secret": "0SivUl28p44BADmQDkTJrJOo7iozN74W"
    },
    "msg": ""
}
修改于 2025-10-11 12:40:12
上一页
删除权限设置
下一页
上传文件分块
Built with