Base64 File Upload
curl --request POST \
--url https://api.aihubmax.com/v1/files/upload/base64 \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"file_data": "iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAADUlEQVR42mNk...",
"file_name": "photo.png",
"auto_cleanup": true
}
'import requests
url = "https://api.aihubmax.com/v1/files/upload/base64"
payload = {
"file_data": "iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAADUlEQVR42mNk...",
"file_name": "photo.png",
"auto_cleanup": True
}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({
file_data: 'iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAADUlEQVR42mNk...',
file_name: 'photo.png',
auto_cleanup: true
})
};
fetch('https://api.aihubmax.com/v1/files/upload/base64', 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://api.aihubmax.com/v1/files/upload/base64",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'file_data' => 'iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAADUlEQVR42mNk...',
'file_name' => 'photo.png',
'auto_cleanup' => true
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json"
],
]);
$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://api.aihubmax.com/v1/files/upload/base64"
payload := strings.NewReader("{\n \"file_data\": \"iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAADUlEQVR42mNk...\",\n \"file_name\": \"photo.png\",\n \"auto_cleanup\": true\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "Bearer <token>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://api.aihubmax.com/v1/files/upload/base64")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"file_data\": \"iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAADUlEQVR42mNk...\",\n \"file_name\": \"photo.png\",\n \"auto_cleanup\": true\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.aihubmax.com/v1/files/upload/base64")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"file_data\": \"iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAADUlEQVR42mNk...\",\n \"file_name\": \"photo.png\",\n \"auto_cleanup\": true\n}"
response = http.request(request)
puts response.read_body{
"id": "file-1757165031-a1b2c3",
"filename": "photo.png",
"url": "https://cdn.foxapi.cc/uploads/20260319/a1b2c3d4e5f6/photo.png",
"size": 204800,
"created": 1757165031
}{
"error": {
"message": "Invalid request parameters",
"type": "invalid_request_error"
}
}{
"error": {
"message": "Invalid API key",
"type": "authentication_error"
}
}{
"error": {
"message": "Access denied",
"type": "permission_error"
}
}{
"error": {
"message": "File too large",
"type": "file_too_large_error"
}
}{
"error": {
"message": "Rate limit exceeded",
"type": "rate_limit_error"
}
}{
"error": {
"message": "Internal server error",
"type": "server_error"
}
}File Upload
File Upload - Base64
- Upload a file using base64-encoded content
- Returns the file ID and accessible URL after successful upload
POST
/
v1
/
files
/
upload
/
base64
Base64 File Upload
curl --request POST \
--url https://api.aihubmax.com/v1/files/upload/base64 \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"file_data": "iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAADUlEQVR42mNk...",
"file_name": "photo.png",
"auto_cleanup": true
}
'import requests
url = "https://api.aihubmax.com/v1/files/upload/base64"
payload = {
"file_data": "iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAADUlEQVR42mNk...",
"file_name": "photo.png",
"auto_cleanup": True
}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({
file_data: 'iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAADUlEQVR42mNk...',
file_name: 'photo.png',
auto_cleanup: true
})
};
fetch('https://api.aihubmax.com/v1/files/upload/base64', 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://api.aihubmax.com/v1/files/upload/base64",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'file_data' => 'iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAADUlEQVR42mNk...',
'file_name' => 'photo.png',
'auto_cleanup' => true
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json"
],
]);
$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://api.aihubmax.com/v1/files/upload/base64"
payload := strings.NewReader("{\n \"file_data\": \"iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAADUlEQVR42mNk...\",\n \"file_name\": \"photo.png\",\n \"auto_cleanup\": true\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "Bearer <token>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://api.aihubmax.com/v1/files/upload/base64")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"file_data\": \"iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAADUlEQVR42mNk...\",\n \"file_name\": \"photo.png\",\n \"auto_cleanup\": true\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.aihubmax.com/v1/files/upload/base64")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"file_data\": \"iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAADUlEQVR42mNk...\",\n \"file_name\": \"photo.png\",\n \"auto_cleanup\": true\n}"
response = http.request(request)
puts response.read_body{
"id": "file-1757165031-a1b2c3",
"filename": "photo.png",
"url": "https://cdn.foxapi.cc/uploads/20260319/a1b2c3d4e5f6/photo.png",
"size": 204800,
"created": 1757165031
}{
"error": {
"message": "Invalid request parameters",
"type": "invalid_request_error"
}
}{
"error": {
"message": "Invalid API key",
"type": "authentication_error"
}
}{
"error": {
"message": "Access denied",
"type": "permission_error"
}
}{
"error": {
"message": "File too large",
"type": "file_too_large_error"
}
}{
"error": {
"message": "Rate limit exceeded",
"type": "rate_limit_error"
}
}{
"error": {
"message": "Internal server error",
"type": "server_error"
}
}Authorizations
All APIs require Bearer Token authentication
Add to request header:
Authorization: Bearer YOUR_API_KEY
Body
application/json
Base64-encoded file content
Example:
"iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAADUlEQVR42mNk..."
Original filename with extension
Example:
"photo.png"
Whether to automatically clean up the earliest uploaded files when storage is insufficient
Notes:
- Default
true: Automatically evicts the earliest uploaded files - Set to
false: Returns a 403 error directly when storage is insufficient
Example:
true
Response
File uploaded successfully
File ID
Example:
"file-1757165031-a1b2c3"
Original filename
Example:
"photo.png"
Accessible URL of the uploaded file
Example:
"https://cdn.foxapi.cc/uploads/20260319/a1b2c3d4e5f6/photo.png"
File size in bytes
Example:
204800
Upload timestamp
Example:
1757165031
⌘I