Skip to content

byteark/byteark-stream-resumable-upload-php-example

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

ByteArk Stream Resumable Upload with PHP

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.

How it works

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

Usage

  1. Clone this project
    • Please noted that Git LFS is required, if you want to use the sample video for testing.
  2. Install the dependencies
composer install
  1. Config the example, by editing variables in main function of the file src/index.php
function main() {
  $bytearkStreamProjectKey = '<your-project-key-here>';
  $bytearkStreamAccessToken = '<your-access-token-here>';
  
  // Remaining code...
}
  1. Try to run the script. This will simulate the uploading via CLI.
php index.php

How I should use this in my project

  • Install the following dependencies in your project:
    • guzzlehttp/guzzle
    • ankitpokhrel/tus-php
    • monolog/monolog (optional)
  • You may copy the whole ByteArkStreamVideoUploader class to your application
  • Then, using the class, just like the code that appears in main function.
// 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);

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages