Skip to content

File Stream Upload ​

Endpoint ​

POST /api/file-stream-upload

Full URL: https://modelfold.ai/api/file-stream-upload

Authentication: every request must include the Authorization: Bearer <API_KEY> header.

INFO

Uploaded files are deleted 24 hours after upload.

Features ​

  • Supports binary stream upload for multiple file types
  • Suitable for large file uploads with high transmission efficiency
  • Automatically identifies MIME types
  • 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

Usage Recommendations ​

  • Recommended for large files (>10MB)
  • Supports multiple formats: images, videos, documents, etc.
  • Avoids the ~33% size overhead of Base64 encoding.

Example Command ​

bash
curl -X POST https://modelfold.ai/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"

Request Parameters ​

Body (multipart/form-data) ​

ParameterTypeRequiredDescription
filestringYesFile to upload (binary data) Example: ``.
uploadPathstringYesFile upload path, without leading or trailing slashes Example: images/user-uploads.
fileNamestringNoFile 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 Example: my-image.jpg.

Request Example ​

bash
curl -X POST "https://modelfold.ai/api/file-stream-upload" \
  -H "Authorization: Bearer $MODELFOLD_API_KEY" \
  -F "file=" \
  -F "uploadPath=images/user-uploads" \
  -F "fileName=my-image.jpg"
json
{
  "file": "",
  "uploadPath": "images/user-uploads",
  "fileName": "my-image.jpg"
}

Response ​

200 — File uploaded successfully ​

ParameterTypeRequiredDescription
successbooleanYesWhether the request was successful
codeintegerYesResponse Status Code
msgstringYesResponse message Example: File uploaded successfully.
dataobjectYes—
  data.fileNamestringYesFile name Example: uploaded-image.png.
  data.filePathstringYesComplete file path in storage Example: images/user-uploads/uploaded-image.png.
  data.downloadUrlstringYesFile download URL Example: https://tempfile.redpandaai.co/xxx/images/user-uploads/uploaded-image.png.
  data.fileSizeintegerYesFile size in bytes Example: 154832.
  data.mimeTypestringYesFile MIME type Example: image/png.
  data.uploadedAtstringYesUpload timestamp Example: 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 ​

ParameterTypeRequiredDescription
successbooleanYesWhether the request was successful
codeintegerYesResponse status code
msgstringYesResponse message Example: File uploaded successfully.
json
{
  "success": false,
  "code": 400,
  "msg": "Missing required parameter: uploadPath"
}

401 — Unauthorized access ​

ParameterTypeRequiredDescription
codeintegerNoStatus 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). Allowed values: 200 / 401 / 402 / 404 / 422 / 429 / 455 / 500 / 501 / 505. Example: 200.
msgstringNoResponse message, error description when failed Example: success.
successbooleanYesWhether the request was successful
json
{
  "success": false,
  "code": 401,
  "msg": "Authentication failed: Invalid API Key"
}

500 — Internal server error ​

ParameterTypeRequiredDescription
successbooleanYesWhether the request was successful
codeintegerYesResponse status code
msgstringYesResponse message Example: File uploaded successfully.
json
{
  "success": false,
  "code": 500,
  "msg": "Internal server error"
}

ModelFold — one API for all the best AI models.