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 file='@example-file' \
--form uploadPath=images/user-uploads \
--form fileName=my-image.jpgimport requests
url = "https://apibox.redpandaai.co/api/file-stream-upload"
files = { "file": ("example-file", open("example-file", "rb")) }
payload = {
"uploadPath": "images/user-uploads",
"fileName": "my-image.jpg"
}
headers = {"Authorization": "Bearer <token>"}
response = requests.post(url, data=payload, files=files, headers=headers)
print(response.text)const form = new FormData();
form.append('file', '<string>');
form.append('uploadPath', 'images/user-uploads');
form.append('fileName', 'my-image.jpg');
const options = {method: 'POST', headers: {Authorization: 'Bearer <token>'}};
options.body = form;
fetch('https://apibox.redpandaai.co/api/file-stream-upload', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://apibox.redpandaai.co/api/file-stream-upload",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => "-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"file\"; filename=\"example-file\"\r\nContent-Type: application/octet-stream\r\n\r\n<string>\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"uploadPath\"\r\n\r\nimages/user-uploads\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"fileName\"\r\n\r\nmy-image.jpg\r\n-----011000010111000001101001--",
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: multipart/form-data"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://apibox.redpandaai.co/api/file-stream-upload"
payload := strings.NewReader("-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"file\"; filename=\"example-file\"\r\nContent-Type: application/octet-stream\r\n\r\n<string>\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"uploadPath\"\r\n\r\nimages/user-uploads\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"fileName\"\r\n\r\nmy-image.jpg\r\n-----011000010111000001101001--")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "Bearer <token>")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://apibox.redpandaai.co/api/file-stream-upload")
.header("Authorization", "Bearer <token>")
.body("-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"file\"; filename=\"example-file\"\r\nContent-Type: application/octet-stream\r\n\r\n<string>\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"uploadPath\"\r\n\r\nimages/user-uploads\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"fileName\"\r\n\r\nmy-image.jpg\r\n-----011000010111000001101001--")
.asString();require 'uri'
require 'net/http'
url = URI("https://apibox.redpandaai.co/api/file-stream-upload")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request.body = "-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"file\"; filename=\"example-file\"\r\nContent-Type: application/octet-stream\r\n\r\n<string>\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"uploadPath\"\r\n\r\nimages/user-uploads\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"fileName\"\r\n\r\nmy-image.jpg\r\n-----011000010111000001101001--"
response = http.request(request)
puts response.read_body{
"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"
}
}File Upload API
File Stream Upload
POST
/
api
/
file-stream-upload
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 file='@example-file' \
--form uploadPath=images/user-uploads \
--form fileName=my-image.jpgimport requests
url = "https://apibox.redpandaai.co/api/file-stream-upload"
files = { "file": ("example-file", open("example-file", "rb")) }
payload = {
"uploadPath": "images/user-uploads",
"fileName": "my-image.jpg"
}
headers = {"Authorization": "Bearer <token>"}
response = requests.post(url, data=payload, files=files, headers=headers)
print(response.text)const form = new FormData();
form.append('file', '<string>');
form.append('uploadPath', 'images/user-uploads');
form.append('fileName', 'my-image.jpg');
const options = {method: 'POST', headers: {Authorization: 'Bearer <token>'}};
options.body = form;
fetch('https://apibox.redpandaai.co/api/file-stream-upload', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://apibox.redpandaai.co/api/file-stream-upload",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => "-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"file\"; filename=\"example-file\"\r\nContent-Type: application/octet-stream\r\n\r\n<string>\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"uploadPath\"\r\n\r\nimages/user-uploads\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"fileName\"\r\n\r\nmy-image.jpg\r\n-----011000010111000001101001--",
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: multipart/form-data"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://apibox.redpandaai.co/api/file-stream-upload"
payload := strings.NewReader("-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"file\"; filename=\"example-file\"\r\nContent-Type: application/octet-stream\r\n\r\n<string>\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"uploadPath\"\r\n\r\nimages/user-uploads\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"fileName\"\r\n\r\nmy-image.jpg\r\n-----011000010111000001101001--")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "Bearer <token>")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://apibox.redpandaai.co/api/file-stream-upload")
.header("Authorization", "Bearer <token>")
.body("-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"file\"; filename=\"example-file\"\r\nContent-Type: application/octet-stream\r\n\r\n<string>\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"uploadPath\"\r\n\r\nimages/user-uploads\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"fileName\"\r\n\r\nmy-image.jpg\r\n-----011000010111000001101001--")
.asString();require 'uri'
require 'net/http'
url = URI("https://apibox.redpandaai.co/api/file-stream-upload")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request.body = "-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"file\"; filename=\"example-file\"\r\nContent-Type: application/octet-stream\r\n\r\n<string>\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"uploadPath\"\r\n\r\nimages/user-uploads\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"fileName\"\r\n\r\nmy-image.jpg\r\n-----011000010111000001101001--"
response = http.request(request)
puts response.read_body{
"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"
}
}Upload temporary files via multipart/form-data format. Note: Uploaded files are temporary and automatically deleted after 3 days.
Features
- Supports binary stream upload for various file types
- Suitable for large file uploads with high transmission efficiency
- Automatic MIME type recognition
- Support for custom file names or using original file names
- Returns complete file information and download links
- API Key authentication protection
- Uploaded files are temporary and automatically deleted after 3 days
Usage Recommendations
- Recommended for large files (>10MB)
- Supports various formats: images, videos, documents, etc.
- Transmission efficiency is approximately 33% higher than Base64 format
Example Command
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"
Authorizations
All APIs require authentication via Bearer Token.
Get API Key:
- Visit API Key Management Page to get your API Key
Usage: Add to request header: Authorization: Bearer YOUR_API_KEY
Note:
- Keep your API Key secure and do not share it with others
- If you suspect your API Key has been compromised, reset it immediately in the management page
Body
multipart/form-data
File to upload (binary data)
File upload path, without leading or trailing slashes
Example:
"images/user-uploads"
File name (optional), including file extension. If not provided, a random file name will be generated. If the same file name already exists, the old file will be overwritten. Note: Due to caching, changes may not take effect immediately.
Example:
"my-image.jpg"
Response
File uploaded successfully
Whether the request was successful
Response Status Code
| Code | Description |
|---|---|
| 200 | Success - Request has been processed successfully |
| 400 | Bad Request - Request parameters are incorrect or missing required parameters |
| 401 | Unauthorized - Authentication credentials are missing or invalid |
| 405 | Method Not Allowed - Request method is not supported |
| 500 | Server Error - An unexpected error occurred while processing the request |
Available options:
200, 400, 401, 405, 500 Response message
Example:
"File uploaded successfully"
Show child attributes
Show child attributes
