With PHP (Server-side), you may upload upload the large video source file to ByteArk Stream with the resumable way, to reduce the changes of uploading failed.
The video will be separately uploaded as multiple chunks (by default is 100MB per chunk). If the uploading failed, it'll wait a bit and retry.
This project is tested with PHP 7.4
- Clone this project
- Please noted that Git LFS is required, if you want to use the sample video for testing.
- Install the dependencies
composer install
- Config the example, by editing variables in
mainfunction of the filesrc/index.php
function main() {
$bytearkStreamProjectKey = '<your-project-key-here>';
$bytearkStreamAccessToken = '<your-access-token-here>';
// Remaining code...
}- Try to run the script. This will simulate the uploading via CLI.
php index.php
- Install the following dependencies in your project:
guzzlehttp/guzzleankitpokhrel/tus-phpmonolog/monolog(optional)
- You may copy the whole
ByteArkStreamVideoUploaderclass to your application - Then, using the class, just like the code that appears in
mainfunction.
// TODO: Try to edit these variables.
// In the production, access token should be stored in a secure way.
$bytearkStreamProjectKey = '<your-project-key-here>';
$bytearkStreamAccessToken = '<your-access-token-here>';
$videoTitle = '<your-video-title-here>';
$videoSourceFilePath = '<your-video-source-file-path-here>';
$uploader = new ByteArkStreamVideoUploader([
'bytearkStreamProjectKey' => $bytearkStreamProjectKey,
'bytearkStreamAccessToken' => $bytearkStreamAccessToken,
]);
$videoKey = $uploader->uploadVideo($videoTitle, $videoSourceFilePath);