Welcome to File Upload API

The File Upload API provides flexible and efficient file upload services, supporting multiple upload methods to meet diverse business needs. Whether it’s remote file migration, large file transmission, or quick small file uploads, our API offers the best solutions for your requirements.
Important Notice: Uploaded files are temporary and will be automatically deleted after 3 days. Please download or migrate important files promptly.

Authentication

All API requests require authentication using Bearer tokens. Please obtain your API key from the API Key Management Page.
Please keep your API key secure and never share it publicly. If you suspect your key has been compromised, reset it immediately.

API Base URL

https://kieai.redpandaai.co

Authentication Header

Authorization: Bearer YOUR_API_KEY

Quick Start Guide

Step 1: Choose Your Upload Method

Select the appropriate upload method based on your needs:
Suitable for downloading and uploading files from remote servers:
curl -X POST "https://kieai.redpandaai.co/api/file-url-upload" \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "fileUrl": "https://example.com/sample-image.jpg",
    "uploadPath": "images",
    "fileName": "my-image.jpg"
  }'

Step 2: Handle Response

Upon successful upload, you’ll receive a response containing file information:
{
  "success": true,
  "code": 200,
  "msg": "File uploaded successfully",
  "data": {
    "fileId": "file_abc123456",
    "fileName": "my-image.jpg",
    "originalName": "sample-image.jpg",
    "fileSize": 245760,
    "mimeType": "image/jpeg",
    "uploadPath": "images",
    "fileUrl": "https://kieai.redpandaai.co/files/images/my-image.jpg",
    "downloadUrl": "https://kieai.redpandaai.co/download/file_abc123456",
    "uploadTime": "2025-01-15T10:30:00Z",
    "expiresAt": "2025-01-18T10:30:00Z"
  }
}

Upload Method Comparison

Choose the most suitable upload method for your needs:

URL File Upload

Best for: File migration, batch processingAdvantages:
  • No local file required
  • Automatic download handling
  • Supports remote resources
Limitations:
  • Requires publicly accessible URL
  • 30-second download timeout
  • Recommended ≤100MB

File Stream Upload

Best for: Large files, local filesAdvantages:
  • High transmission efficiency
  • Supports large files
  • Binary transmission
Limitations:
  • Requires local file
  • Server processing time

Base64 Upload

Best for: Small files, API integrationAdvantages:
  • JSON format transmission
  • Easy integration
  • Supports Data URL
Limitations:
  • Data size increases by 33%
  • Not suitable for large files
  • Recommended ≤10MB

Practical Examples

Batch File Upload

Using file stream upload to handle multiple files:
class FileUploadAPI {
  constructor(apiKey) {
    this.apiKey = apiKey;
    this.baseUrl = 'https://kieai.redpandaai.co';
  }
  
  async uploadFile(file, uploadPath = '', fileName = null) {
    const formData = new FormData();
    formData.append('file', file);
    if (uploadPath) formData.append('uploadPath', uploadPath);
    if (fileName) formData.append('fileName', fileName);
    
    const response = await fetch(`${this.baseUrl}/api/file-stream-upload`, {
      method: 'POST',
      headers: {
        'Authorization': `Bearer ${this.apiKey}`
      },
      body: formData
    });
    
    if (!response.ok) {
      throw new Error(`Upload failed: ${response.statusText}`);
    }
    
    return response.json();
  }
  
  async uploadFromUrl(fileUrl, uploadPath = '', fileName = null) {
    const response = await fetch(`${this.baseUrl}/api/file-url-upload`, {
      method: 'POST',
      headers: {
        'Authorization': `Bearer ${this.apiKey}`,
        'Content-Type': 'application/json'
      },
      body: JSON.stringify({
        fileUrl,
        uploadPath,
        fileName
      })
    });
    
    if (!response.ok) {
      throw new Error(`Upload failed: ${response.statusText}`);
    }
    
    return response.json();
  }
  
  async uploadBase64(base64Data, uploadPath = '', fileName = null) {
    const response = await fetch(`${this.baseUrl}/api/file-base64-upload`, {
      method: 'POST',
      headers: {
        'Authorization': `Bearer ${this.apiKey}`,
        'Content-Type': 'application/json'
      },
      body: JSON.stringify({
        base64Data,
        uploadPath,
        fileName
      })
    });
    
    if (!response.ok) {
      throw new Error(`Upload failed: ${response.statusText}`);
    }
    
    return response.json();
  }
}

// Usage example
const uploader = new FileUploadAPI('YOUR_API_KEY');

// Batch upload files
async function uploadMultipleFiles(files) {
  const results = [];
  
  for (let i = 0; i < files.length; i++) {
    try {
      const result = await uploader.uploadFile(
        files[i], 
        'user-uploads', 
        `file-${i + 1}-${files[i].name}`
      );
      results.push(result);
      console.log(`File ${i + 1} uploaded successfully:`, result.data.fileUrl);
    } catch (error) {
      console.error(`File ${i + 1} upload failed:`, error.message);
    }
  }
  
  return results;
}

// Batch upload from URLs
async function uploadFromUrls(urls) {
  const results = [];
  
  for (let i = 0; i < urls.length; i++) {
    try {
      const result = await uploader.uploadFromUrl(
        urls[i], 
        'downloads', 
        `download-${i + 1}.jpg`
      );
      results.push(result);
      console.log(`URL ${i + 1} uploaded successfully:`, result.data.fileUrl);
    } catch (error) {
      console.error(`URL ${i + 1} upload failed:`, error.message);
    }
  }
  
  return results;
}

Error Handling

Common errors and handling methods:

Best Practices

File Storage Information

Important Notice: All uploaded files are temporary and will be automatically deleted after 3 days.
  • Files are immediately accessible and downloadable after upload
  • File URLs remain valid for 3 days
  • The system provides an expiresAt field in the response indicating expiration time
  • It’s recommended to download or migrate important files before expiration
  • Use the downloadUrl field to get direct download links

Status Codes

200
Success
Request processed successfully, file upload completed
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, please check HTTP method
500
Server Error
An unexpected error occurred while processing the request, please retry or contact support

Next Steps

Support

Need help? Our technical support team is here to assist you.

Ready to start uploading files? Get your API key and begin using the file upload service immediately!