调用 API 前必须先获取 API Key

所有 API 请求均需通过 X-API-Key 请求头进行身份认证。没有有效的 API Key,任何端点都无法调用。

API 上传指南

上传流程

API 上传分为两步:获取预签名 → 上传文件。

步骤一:获取预签名

curl -X POST https://imgroute.com/api/presign \
  -H "X-API-Key: sk-ir-your-api-key" \
  -H "Content-Type: application/json" \
  -d '{
    "file_name": "example.png",
    "file_size": 204800,
    "mime_type": "image/png"
  }'

成功响应示例:

{
  "upload_token": "token_xxx",
  "upload_url": "http://io-node:8080/upload",
  "image_id": "img_abc123"
}

步骤二:上传文件

使用步骤一获取的 upload_tokenupload_url

curl -X POST "http://io-node:8080/upload?token=token_xxx" \
  -F "file=@example.png"

支持的格式

格式 扩展名
PNG .png
JPEG .jpg, .jpeg
GIF .gif
WebP .webp
SVG .svg
BMP .bmp
TIFF .tiff, .tif
ICO .ico

访问上传的图片

上传成功后,通过以下 URL 访问:

https://cdn.imgroute.com/i/{image_id}