API 文档

私有文件存储 API 使用指南

⚠️ 上传的文件为私有存储,需要签名 URL 才能访问

API 文档

POST /api/upload/file

通过 multipart/form-data 上传文件

curl -X POST 'https://private-storage-api.sinancode.com/api/upload/file' \
  -H 'Authorization: Bearer YOUR_TOKEN' \
  -F 'file=@/path/to/file.png'

POST /api/upload/base64

通过 Base64 数据上传

curl -X POST 'https://private-storage-api.sinancode.com/api/upload/base64' \
  -H 'Authorization: Bearer YOUR_TOKEN' \
  -H 'Content-Type: application/json' \
  -d '{"data": "data:image/png;base64,iVBORw0KGgo..."}'

POST /api/upload/url

通过远程 URL 上传

curl -X POST 'https://private-storage-api.sinancode.com/api/upload/url' \
  -H 'Authorization: Bearer YOUR_TOKEN' \
  -H 'Content-Type: application/json' \
  -d '{"url": "https://example.com/image.png"}'

响应格式

{
  "url": "https://...带签名的私有访问URL",
  "key": "uploads/{user_id}/{hash}.{ext}",
  "md5": "d41d8cd98f00b204e9800998ecf8427e",
  "size": 12345,
  "content_type": "image/png",
  "expires_at": "2024-01-17T00:00:00.000Z"
}