This document describes how to authenticate and upload videos to the API. It includes required headers, fields, responses, and sample client code.
Use multipart/form-data to send the video file and metadata. Authentication uses a user-specific API token.
Place the api_token to you form.
multipart/form-dataapplication/jsonmp4, mkv, flv, wmv. Default max size: 20GB. <form id="uploadForm" onsubmit="handleUpload(event)">
<input type="hidden" name="api_token" value="PUT_YOUR_API_TOKEN" required>
<input type="text" name="title" id="title" placeholder="Video title (optional)">
<input type="text" name="description" id="description" placeholder="Video Description (optional)">
<input type="file" name="video" id="videoInput" required>
<input type="submit" value="Upload Video">
<div id="progress" style="margin-top:10px;">0%<div>
<div id="status" style="font-size: 12px; color: #666;"><div>
</form>
<script>
// 1. Configuration
const CHUNK_SIZE = 5 * 1024 * 1024; // 5MB
const UPLOAD_URL = 'https://bigshare.io/api/videos/file';
const MERGE_URL = 'https://bigshare.io/api/videos/merge';
async function handleUpload(event) {
event.preventDefault(); // Stop standard form submission
const fileInput = document.getElementById('videoInput');
const file = fileInput.files[0];
const statusDiv = document.getElementById('status');
const progressDiv = document.getElementById('progress');
if (!file) {
alert("Please select a file.");
return;
}
// 2. Prepare Data
const totalChunks = Math.ceil(file.size / CHUNK_SIZE);
const fileName = file.name;
const token = document.querySelector('input[name="api_token"]').value;
const title = document.getElementById('title').value;
const description = document.getElementById('description').value;
statusDiv.innerText = "Uploading...";
try {
// 3. Upload Loop
for (let chunkIndex = 0; chunkIndex < totalChunks; chunkIndex++) {
// Create the slice
const start = chunkIndex * CHUNK_SIZE;
const end = Math.min(file.size, start + CHUNK_SIZE);
const blob = file.slice(start, end);
// Create FormData
const formData = new FormData();
formData.append('video', blob);
formData.append('fileName', fileName);
formData.append('chunkIndex', chunkIndex);
formData.append('api_token', token);
if (chunkIndex === 0) {
formData.append('title', title);
formData.append('description', description);
}
// Send Chunk
const response = await fetch(UPLOAD_URL, {
method: 'POST',
body: formData
});
if (!response.ok) {
throw new Error(`Chunk ${chunkIndex} failed to upload.`);
}
// Update UI
const percent = Math.round(((chunkIndex + 1) / totalChunks) * 100);
progressDiv.innerText = percent + '%';
}
// 4. Merge Process
statusDiv.innerText = "Finalizing (Merging chunks)...";
const mergeData = new FormData();
mergeData.append('fileName', fileName);
mergeData.append('totalChunks', totalChunks);
mergeData.append('api_token', token);
mergeData.append('title', title);
mergeData.append('description', description);
const mergeResponse = await fetch(MERGE_URL, {
method: 'POST',
body: mergeData
});
if (!mergeResponse.ok) {
throw new Error("Failed to merge video on server.");
}
statusDiv.innerText = "Upload Complete!";
alert("Success!");
} catch (error) {
console.error(error);
statusDiv.innerText = "Error: " + error.message;
alert("Upload failed: " + error.message);
}
}
</script>
Use direct video url to send the video file. Authentication uses a user-specific API token.
Place the api_token to you form.
application/jsonapplication/jsonmp4, mkv, flv, wmv. Default max size: 20GB.<?php
$postFields = [
'url' => 'https://DIRECT_VIDEO_FILE',
'api_token' => 'YOUR_API_TOKEN',
'title' => 'Custom Title',
'description' => 'description about video',
];
$options = [
'http' => [
'method' => 'POST',
'header' =>
"Content-Type: application/json\r\n" .
"Accept: application/json\r\n",
'content' => json_encode($postFields)
]
];
$context = stream_context_create($options);
$response = file_get_contents('https://bigshare.io/api/videos/url', false, $context);
echo $response;
Get the list of uploaded files. Authentication uses a user-specific API token.
Place the api_token to you form.
application/jsonapplication/json<?php
$apiUrl = "https://bigshare.io/api/videos/list?page=10";
$postFields = [
'api_token' => 'YOUR_API_TOKEN',
];
$ch = curl_init();
curl_setopt_array($ch, [
CURLOPT_URL => $apiUrl,
CURLOPT_POST => true,
CURLOPT_POSTFIELDS => $postFields,
CURLOPT_RETURNTRANSFER => true,
CURLOPT_HTTPHEADER => [
"Accept: application/json"
],
]);
$response = curl_exec($ch);
if (curl_errno($ch)) {
echo "Error: " . curl_error($ch);
} else {
echo "Response: " . $response;
}
curl_close($ch);