Skip to main content
POST
/
api
/
upload
/
base64
Upload file via Base64 data URL
curl --request POST \
  --url https://files-api.sinancode.com/api/upload/base64 \
  --header 'Authorization: Bearer <token>' \
  --header 'Content-Type: application/json' \
  --data '
{
  "data": "data:image/png;base64,iVBORw0KGgo..."
}
'
{
  "url": "https://upload-tmp.sinancode.com/uploads/user123/abc123def456.png",
  "cn_url": "https://beijing-user-upload-tmp.tos-cn-beijing.volces.com/uploads/user123/abc123def456.png",
  "key": "uploads/user123/abc123def456.png",
  "md5": "d41d8cd98f00b204e9800998ecf8427e",
  "size": 12345,
  "content_type": "image/png",
  "expires_at": "2024-01-17T00:00:00.000Z"
}
Upload files to cloud storage using Base64 data URL format. Key Features:
  • Frontend Friendly - Ideal for Canvas, screenshots, and direct upload scenarios
  • Auto Parsing - Automatically detects MIME type from data URL prefix
  • Large File Support - Supports files up to 50MB
  • Dual Access - Returns both global and China access URLs

Authorizations

Authorization
string
header
required

Authorization token obtained from api.sinancode.com

Body

application/json
data
string
required

Base64 data URL in format: data:{mime-type};base64,{base64-data}

Example:

"data:image/png;base64,iVBORw0KGgo..."

Response

File uploaded successfully

url
string<uri>
required

Public URL to access the uploaded file (global)

Example:

"https://upload-tmp.sinancode.com/uploads/user123/abc123def456.png"

cn_url
string<uri>
required

Public URL to access the uploaded file (China)

Example:

"https://beijing-user-upload-tmp.tos-cn-beijing.volces.com/uploads/user123/abc123def456.png"

key
string
required

Storage key of the uploaded file

Example:

"uploads/user123/abc123def456.png"

md5
string
required

Hash of the file content (SHA-256 truncated)

Example:

"d41d8cd98f00b204e9800998ecf8427e"

size
integer
required

File size in bytes

Example:

12345

content_type
string
required

MIME type of the file

Example:

"image/png"

expires_at
string<date-time>
required

Expiration time of the file (ISO 8601)

Example:

"2024-01-17T00:00:00.000Z"