curl --request POST \
--url https://apibox.redpandaai.co/api/file-stream-upload \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: multipart/form-data' \
--form uploadPath=images/user-uploads \
--form fileName=profile-picture.jpg \
--form file='@example-file'{
"success": true,
"code": 200,
"msg": "文件上传成功",
"data": {
"fileName": "uploaded-image.png",
"filePath": "images/user-uploads/uploaded-image.png",
"downloadUrl": "https://tempfile.redpandaai.co/xxx/images/user-uploads/uploaded-image.png",
"fileSize": 154832,
"mimeType": "image/png",
"uploadedAt": "2025-01-01T12:00:00.000Z"
}
}文件上传API
文件流上传
POST
/
api
/
file-stream-upload
curl --request POST \
--url https://apibox.redpandaai.co/api/file-stream-upload \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: multipart/form-data' \
--form uploadPath=images/user-uploads \
--form fileName=profile-picture.jpg \
--form file='@example-file'{
"success": true,
"code": 200,
"msg": "文件上传成功",
"data": {
"fileName": "uploaded-image.png",
"filePath": "images/user-uploads/uploaded-image.png",
"downloadUrl": "https://tempfile.redpandaai.co/xxx/images/user-uploads/uploaded-image.png",
"fileSize": 154832,
"mimeType": "image/png",
"uploadedAt": "2025-01-01T12:00:00.000Z"
}
}上传的文件为临时文件,3天后自动删除。
功能特点
- 支持多种文件类型的二进制流上传
- 适合大文件上传,传输效率高
- 自动识别 MIME 类型
- 支持自定义文件名或使用原文件名
- 返回完整的文件信息和下载链接
- API Key 认证保护
- 上传文件为临时文件,3天后自动删除
使用建议
- 推荐用于大文件(>10MB)
- 支持多种格式:图片、视频、文档等
- 传输效率比 Base64 格式高约 33%
示例命令
curl -X POST https://apibox.redpandaai.co/api/file-stream-upload \
-H "Authorization: Bearer YOUR_API_KEY" \
-F "file=@/path/to/your-file.jpg" \
-F "uploadPath=images/user-uploads" \
-F "fileName=custom-name.jpg"
授权
所有 API 需要通过 Bearer Token 进行身份验证。
获取 API Key:
- 访问 API Key 管理页面 获取您的 API Key
使用方法: 在请求头中添加: Authorization: Bearer YOUR_API_KEY
注意:
- 请妥善保管您的 API Key,不要与他人分享
- 如果怀疑 API Key 已泄露,请立即在管理页面重置
请求体
multipart/form-data
