Skip to main content

Chunked Uploads

For large files (up to 5GB) or unreliable network connections, use the Chunked Upload API. This allows you to split your file into smaller parts and upload them sequentially. If an upload fails, you can resume from the last successful chunk.

1. Check Upload Status

Before starting or resuming an upload, check the status of the file on the server.

Method: GET Endpoint: https://api.xenonflare.com/media/chunks

Query Parameters

ParameterTypeRequiredDescription
fileIdstringYesA unique identifier for your file (e.g., a UUID generated by your client).

Response

{
"success": true,
"data": {
"exists": true,
"currentSize": 10485760, // Total bytes received so far
"fileId": "your-unique-file-id"
}
}

If exists is false, start uploading from byte 0. If true, you can resume uploading from currentSize.

2. Upload a Chunk

Upload a specific chunk of the file.

Method: POST Endpoint: https://api.xenonflare.com/media/chunks

Headers

  • Content-Type: multipart/form-data

Body (Form Data)

FieldTypeRequiredDescription
fileFileYesThe binary data for this chunk.
chunkIndexnumberYesThe 0-based index of this chunk.
totalChunksnumberYesThe total number of chunks.
fileIdstringYesThe same unique identifier used in the status check.

Response (Chunk Received)

{
"success": true,
"data": {
"completed": false,
"chunkIndex": 0
},
"message": "Chunk received"
}

Response (Upload Complete)

When the last chunk is received:

{
"success": true,
"data": {
"completed": true,
"fileId": "your-unique-file-id"
},
"message": "Upload complete"
}

3. Finalize Upload

Once the upload is marked as completed, you must call the Video Upload or Image Upload endpoint to create the media entry.

Instead of sending the file, you verify the fileId.

Example: Finalizing Video Upload

curl -X POST https://api.xenonflare.com/media/videos \
-H "X-API-Key: your_api_key" \
-F "fileId=your-unique-file-id" \
-F "platforms=[\"youtube\"]" \
-F "youtube={\"title\": \"My Chunked Video\"}"