Skip to main content

File Storage API

The Storage API provides temporary file storage powered by Cloudflare R2. Upload files via multiple methods and access them through a global CDN.

Features

  • Multiple Upload Methods: Base64, multipart/form-data, or remote URL
  • Global CDN: Files served through Cloudflare’s edge network
  • Automatic Expiration: Files automatically deleted after 1 day
  • China Acceleration: Dedicated China endpoint for faster access

Authentication

All upload endpoints require Bearer token authentication:
Authorization: Bearer YOUR_API_KEY
You can obtain an API key from the FFHub Dashboard.

Base URL

https://files-api.ffhub.io

Quick Example

curl -X POST https://files-api.ffhub.io/api/upload/file \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -F "file=@/path/to/image.png"

Response Format

All upload endpoints return the same response format:
{
  "url": "https://storage.ffhub.io/uploads/{user_id}/{hash}.png",
  "cn_url": "https://beijing-user-upload-tmp.tos-cn-beijing.volces.com/uploads/{user_id}/{hash}.png",
  "key": "uploads/{user_id}/{hash}.png",
  "md5": "d41d8cd98f00b204e9800998ecf8427e",
  "size": 12345,
  "content_type": "image/png",
  "expires_at": "2024-01-17T00:00:00.000Z"
}

Upload Methods

MethodEndpointUse Case
File UploadPOST /api/upload/fileDirect file upload via form data
Base64POST /api/upload/base64Encoded data from browsers or APIs
URLPOST /api/upload/urlDownload and store remote files

Limits

  • Maximum file size: 1 GB
  • File expiration: 1 day
Files are automatically deleted after 1 day. This service is designed for temporary storage only. For permanent storage, download the files before they expire.

Next Steps