Base64 File Upload
This page is generated from the upstream official OpenAPI documentation. Endpoints, parameters and examples match the official docs; brand and API domain are replaced with ModelFold.
Endpoint
POST /api/file-base64-upload
Full URL: https://ai.modelfold.online/api/file-base64-upload
Authentication: every request must include the
Authorization: Bearer <API_KEY>header.
INFO
Uploaded files are deleted 24 hours after upload.
Features
- Supports Base64 encoded data and data URL formats
- The MIME type and extension are taken from the data URL prefix (e.g. data:image/png;base64,...) or from the fileName extension.
- Supports custom filenames or auto-generation (identical filenames will overwrite old files, potential caching delays may occur)
- Returns complete file information and download links
- Protected by API Key authentication
Supported Formats
- Plain Base64 strings:
iVBORw0KGgoAAAANSUhEUgAA... - Data URL format:
data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAA...
Usage Recommendations
- Recommended for small files such as images
- Large files (>10MB) should use the File Stream Upload API
- Base64 encoding increases data transmission volume by approximately 33%
Request Parameters
Body (application/json)
| Parameter | Type | Required | Description |
|---|---|---|---|
base64Data | string | Yes | Base64 encoded file data. Supports pure Base64 strings or data URL format 示例:data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAA...。 |
uploadPath | string | Yes | File upload path, without leading or trailing slashes 示例:images/base64。 |
fileName | string | No | File name (optional), including file extension. If not provided, a random file name will be generated. If the same file name is uploaded again, the old file will be overwritten, but changes may not take effect immediately due to caching 示例:my-image.png。 |
Request Example
bash
curl -X POST "https://ai.modelfold.online/api/file-base64-upload" \
-H "Authorization: Bearer $MODELFOLD_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"base64Data": "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAA...",
"uploadPath": "images/base64",
"fileName": "my-image.png"
}'json
{
"base64Data": "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAA...",
"uploadPath": "images/base64",
"fileName": "my-image.png"
}Response
200 — File uploaded successfully
| 参数 | 类型 | 必填 | 说明 |
|---|---|---|---|
success | boolean | 是 | Whether the request was successful |
code | integer | 是 | Response Status Code |
msg | string | 是 | Response message 示例:File uploaded successfully。 |
data | object | 是 | — |
data.fileName | string | 是 | File name 示例:uploaded-image.png。 |
data.filePath | string | 是 | Complete file path in storage 示例:images/user-uploads/uploaded-image.png。 |
data.downloadUrl | string | 是 | File download URL 示例:https://tempfile.redpandaai.co/xxx/images/user-uploads/uploaded-image.png。 |
data.fileSize | integer | 是 | File size in bytes 示例:154832。 |
data.mimeType | string | 是 | File MIME type 示例:image/png。 |
data.uploadedAt | string | 是 | Upload timestamp 示例:2025-01-01T12:00:00.000Z。 |
json
{
"success": true,
"code": 200,
"msg": "File uploaded successfully",
"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"
}
}400 — Request parameter error
| 参数 | 类型 | 必填 | 说明 |
|---|---|---|---|
success | boolean | 是 | Whether the request was successful |
code | integer | 是 | Response status code |
msg | string | 是 | Response message 示例:File uploaded successfully。 |
json
{
"success": false,
"code": 400,
"msg": "Missing required parameter: uploadPath"
}401 — Unauthorized access
| 参数 | 类型 | 必填 | 说明 |
|---|---|---|---|
code | integer | 否 | Status code of the request. The HTTP status is 200 even when the request fails, so always check this field: 200 means success; any other value means the request failed and msg describes the reason. Common values: 401 invalid or missing API key; 402 insufficient credits; 429 rate limit exceeded; 422 or 500 the request could not be processed (read msg and check your parameters before retrying). 可选值:200 / 401 / 402 / 404 / 422 / 429 / 455 / 500 / 501 / 505。 示例:200。 |
msg | string | 否 | Response message, error description when failed 示例:success。 |
success | boolean | 是 | Whether the request was successful |
json
{
"success": false,
"code": 401,
"msg": "Authentication failed: Invalid API Key"
}500 — Internal server error
| 参数 | 类型 | 必填 | 说明 |
|---|---|---|---|
success | boolean | 是 | Whether the request was successful |
code | integer | 是 | Response status code |
msg | string | 是 | Response message 示例:File uploaded successfully。 |
json
{
"success": false,
"code": 500,
"msg": "Internal server error"
}