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 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
Expected behavior
When both (temporary and final file system) are the same remote file system, use the copy method.
Steps to reproduce
clone the added repo
setup s3 with
try uploading a file
Add logs in the vendor/spatie/laravel-medialibrary/src/MediaCollections/FileAdder.php file on line 456
Reproduction repository (issue will be closed if this is not valid)
Package
filament/spatie-laravel-media-library-plugin
Package Version
v3.2.115
Laravel Version
v10.48.22
Livewire Version
v3.5.6
PHP Version
8.1.29
Problem description
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:
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
Expected behavior
When both (temporary and final file system) are the same remote file system, use the copy method.
Steps to reproduce
Reproduction repository (issue will be closed if this is not valid)
https://github.com/jornwildenbeest/filament-issues-video
Relevant log output
No response
Donate 💰 to fund this issue