Skip to content

uploader to uplaod chunks of a file and combine them use to upload big files.

License

Notifications You must be signed in to change notification settings

sjelfull-forks/chunks-uploader

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

24 Commits
 
 
 
 
 
 
 
 

Repository files navigation

chunks-uploader

Software License Packagist Version Packagist

Uploader to uplaod chunks of a file and combine them use to upload big files.

Installation

composer require mehrdad-dadkhah/chunks-uploader

Usage

use MehrdadDadkhah\Video\ChunksUploader;

$uploadHandeler = new ChunksUploader();
$uploadHandeler->setMainFileName('myFile.mp4') //main file name
            ->setFileTotalSize($_REQUEST['totalfilesize']) //size of main file (big file)
            ->setInputName('file') //your form input file name
            ->setChunksFolderPath('path-to-chunks-folder') //path to folder for upload chunks files
            ->setUniqueIdentifier('unique-id'); // set unique identifier for each upload (for example user id + time or ...) a unique indentifier per each upload

to upload your chunks:

$uploadResult = $uploadHandeler->uploadChunk('name-of-chunk-or-chunk-number'); //should be a sortable name

And when all chunks upload:

$uploadResult = $uploadHandeler->setUploadDirectory('path-to-upload-directory') //main directry path to upload (combine chunks here)
			->finishUpload();

Custome file name

If want to set output file name try use setUploadName() function before fire finishUpload() function:

$uploadHandeler->setUploadName('my-name.mp4');

If don't set name your file name be with structur YYYY_m_d_hashname.mp4 and in final resutl generated name will be return.

Check and generate output directory

If want to script make output directory automatically just set it:

$uploadHandeler->checkAndGenerateOutputDirectory();

Temp directory

If want to generate file in a temp directory and then move to main upload directory you can use setTempDirectory() function:

$uploadHandeler->setTempDirectory('path-to-temp');

Max upload size

ChunksUploader calculate uploaded file size (sum of chunks) and compare with upload_max_filesize ini config. If want to stop bigger file at first request for better ux can pass total main file size in bytes:

$uploadHandeler->setVideoTotalSize(213456);

And can overwrite upload_max_filesize by:

$uploadHandeler->setMaxUploadSize(213456);

License

hls-video-generater is licensed under the GPLv3 License.

About

uploader to uplaod chunks of a file and combine them use to upload big files.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • PHP 100.0%