maxkhim / filament-dedupler-uploader
Plugin for uploading and automatic deduplication files in Filament
Package info
github.com/maxkhim/filament-dedupler-uploader
pkg:composer/maxkhim/filament-dedupler-uploader
Requires
- php: ^8.1
- filament/filament: ^4.0 || ^5.0
- maxkhim/laravel-storage-dedupler: ^1.0
- spatie/laravel-package-tools: ^1.15.0
Requires (Dev)
None
Suggests
None
Provides
None
Conflicts
None
Replaces
None
README
Dedupler Uploader: DRY for your Storage
Overview
filament-dedupler-uploader is plugin for Filament that prevents duplicate file storage by detecting files with identical content before saving them to storage.
Instead of storing multiple copies of the same file, it uses content-based hashing (SHA1) to ensure each unique file is stored only once - regardless of how many times or by whom it is uploaded.
This is especially useful for applications where users frequently upload the same documents, images, or other files, helping to:
- Save disk space by eliminating redundant copies
- Maintain data integrity through content-based identification
- Reduce storage costs especially for SSD storage in 2026 ;)
Key Features
- 🔍 Automatic deduplication - Files are compared by SHA1 hash before storage
- 📦 Seamless integration - Based on Filament's
FileUploadcomponent - 🔗 Smart relationships - Attaches
uniqueFilesrecords to Eloquent models via theDeduplabletrait - 📋 Infolist components - Display uploaded files with metadata (original name, size, SHA1 hash, download)
- 🗂️ Multiple file support - Handles single and multiple file uploads
Requirements
- PHP 8.1+
- Laravel 12+
- Filament 5.x
🚀 Quick Start
1. Install the package
composer require maxkhim/filament-dedupler-uploader php artisan dedupler:install php artisan dedupler:check
2. Add the Plugin
use Maxkhim\FilamentDeduplerUploader\FilamentDeduplerUploaderPlugin; public function panel(Panel $panel): Panel { return $panel // ... ->plugins([ FilamentDeduplerUploaderPlugin::make() ]); }
3. Prepare Your Model
Your Eloquent model can use the Deduplable trait from laravel-storage-dedupler for simplicity linking files:
use Illuminate\Database\Eloquent\Model; use Maxkhim\Dedupler\Traits\Deduplable; class Document extends Model { use Deduplable; // The trait provides the relationship and attachUniqueFile() method }
4. Use the DeduplerFileUploader Component
Based on Filament's FileUpload component
use Maxkhim\FilamentDeduplerUploader\Forms\Components\DeduplerFileUploader; DeduplerFileUploader::make('attachment') ->multiple()
5. Display Uploaded Files
Displays files in a table with original name, size, download button, and SHA1 hash, using standard Filament components under hood:
use Maxkhim\FilamentDeduplerUploader\Infolists\DeduplerFilesRepeatableEntry; use Filament\Infolists\Components\Section; use Filament\Infolists\Components\TextEntry; use Filament\Infolists\Infolist; public function infolist(Infolist $infolist): Infolist { return $infolist->schema([ Section::make('Uploaded Files') ->schema([ DeduplerFilesRepeatableEntry::make() ->label('Documents'), ]), ]); }
How It Works
Upload Flow
- User uploads a file in the Filament form and saves record
- SHA1 hash is computed from the file content
- Deduplication check - If a file with the same hash already exists in storage, it is reused instead of being saved again
- Relationship attachment - The polymorphic
uniqueFilesrecord attribute is attached to the model via theDeduplabletrait - Form submission - The file path and SHA1 hash is stored in the database
Deletion Behavior
Physical file deletion is managed by the laravel-storage-dedupler package. When a file is removed from a model, the relationship is detached.
License
The MIT License (MIT). Please see License File for more information.
Credits
This package is built on top of maxkhim/laravel-storage-dedupler.
