This package help you to handle chunk files in Laravel easily, and at the end it convert files to one file.
You can download it via composer.
composer require aminrafiei/laravel-chunker
php artisan migrate
For publish config files:
php artisan vendor:publish
- PHP v7.3 or above
- Laravel v7.0 or above
This package use disk driver for store files and write chunk files in laravel storage path if you need another path or another driver use can edit in config file.
Also you can implement your own storage driver by implement FileServiceContract
return [
'save_path' => storage_path('chunker'),
'storage_driver' => \Aminrafiei\Chunker\Services\File\SimpleDiskService::class,
];
In 3 steps you can handle chunk files!
First init then make in progress then make it done!
For initialize chunk file porcess you should use:
use Aminrafiei\Chunker\Facades\Chunker;
$chunkId = Chunker::init($name, $type, $totalChunks, $totalSize);
For handle chunk files and store use should use:
use Aminrafiei\Chunker\Facades\Chunker;
Chunker::progress($chunkId, $chunkNumber, $file);
At the end when all chunk files uploaded for combine to one file you should call:
use Aminrafiei\Chunker\Facades\Chunker;
$response = Chunker::done($chunkId);
$path = $response->getRealPath();