filament/spatie-laravel-media-library-plugin
v3.2.115
v10.48.22
v3.5.6
8.1.29
When uploading files to a remote file system (amazon s3 for example) the filament package does not make use of the copy file method that spatie medialibrary provides, but always uploads the temporary file again. Even when the temporary file system is also pointed to the remote file system. This causes slow file uploads with larger files.
By default it uses the File class instead of RemoteFile class.
This is because the SpatieMediaLibraryFileUpload class uses the addMediaFromString method instead of the
addMediaFromDisk method: https://github.com/filamentphp/filament/blob/3.x/packages/spatie-laravel-media-library-plugin/src/Forms/Components/SpatieMediaLibraryFileUpload.php#L143
I believe this can be fixed by changed the code on line 143 to:
$disk = config('filament.default_filesystem_disk');
$pathToTemporaryLivewireFile = (string) Str::of($file->getRealPath())
->after(Storage::disk($disk)->path('/'))
->ltrim('/');
/** @var FileAdder $mediaAdder */
$mediaAdder = $record->addMediaFromDisk($pathToTemporaryLivewireFile, $disk);
This significantly improves the performance of large file uploads to a remote S3 server since the files do not need to be downloaded and re-uploaded by the laravel application
When both (temporary and final file system) are the same remote file system, use the copy method.
https://github.com/jornwildenbeest/filament-issues-video
No response
Pay now to fund the work behind this issue.
Get updates on progress being made.
Maintainer is rewarded once the issue is completed.
You're funding impactful open source efforts
You want to contribute to this effort
You want to get funding like this too