| Install | |
|---|---|
composer require iperamuna/filament-chunk-upload |
|
| Latest Version: | 1.0.0 |
| PHP: | ^8.2 |
A Filament form component that enables chunked file uploads using FilePond, powered by rahulhaque/laravel-filepond. This package is designed to handle large file uploads reliably by splitting them into smaller chunks.
rahulhaque/laravel-filepond package installed and configuredYou can install the package via composer:
composer require iperamuna/filament-chunk-upload
Ensure you have configured rahulhaque/laravel-filepond according to its documentation.
After installing the package, publish the configuration and migration files:
php artisan vendor:publish --provider="RahulHaque\Filepond\FilepondServiceProvider"
Run the migrations to create the temporary file storage table:
php artisan migrate
Update your .env file to configure the disk and URL for FilePond:
FILEPOND_DISK=private
FILEPOND_TEMP_DISK=local
FILEPOND_URL=/filepond
Make sure your config/filesystems.php has a private disk defined if you choose to use it (recommended for secure uploads).
'private' => [
'driver' => 'local',
'root' => storage_path('app/private'),
'visibility' => 'private',
],
use Iperamuna\FilamentChunkUpload\ChunkedFileUpload in your Filament resources or forms:
use Iperamuna\FilamentChunkUpload\ChunkedFileUpload;
ChunkedFileUpload::make('attachment')
->label('Upload File')
->chunkSize(10485760) // Optional: Set chunk size in bytes (default 10MB)
->directory('uploads')
->visibility('private')
->required();
chunkSize.Since this package is designed for large files often stored on a private disk, you should use a streamed download response to avoid memory exhaustion (OOM) errors in PHP.
Add a route to your routes/web.php to handle secure, signed downloads:
use Illuminate\Support\Facades\Storage;
Route::get('/attachments/{attachment}/download', function (App\Models\Attachment $attachment) {
// 1. Verify Signed URL for security
if (! request()->hasValidSignature()) {
abort(403);
}
$diskName = config('filament.default_disk', 'private');
// 2. Stream the file to the client
// We use streamDownload with manual buffer clearing to prevent memory issues with large files
return response()->streamDownload(function () use ($diskName, $attachment) {
$stream = Storage::disk($diskName)->readStream($attachment->file_path);
// Clear output buffer to prevent OOM
if (ob_get_level()) {
ob_end_clean();
}
fpassthru($stream);
if (is_resource($stream)) {
fclose($stream);
}
}, $attachment->file_name);
})->name('attachments.download');
You can then generate a download link in your Filament resource or Blade view:
use Illuminate\Support\Facades\URL;
URL::signedRoute('attachments.download', ['attachment' => $record->id]);
Please see CHANGELOG for more information on what has changed recently.
The MIT License (MIT). Please see License File for more information.