Optimizing file upload for large files avoid slow move on save
Hi everyone,
I am using the
FileUpload
component to upload very large files (3 to 10GB) to an S3 bucket, and it works well after adjusting all the relevant settings for Livewire, PHP, etc.
However, from what I understand, the file is first uploaded to tmp/ and then moved to the final location.
The moving process on save can be extremely slow—sometimes up to a minute. This isn't great for user experience since filepond.js indicates that the file has already been uploaded.
Is there anything that could be done to either move the file asynchronously or upload it directly to the final location? (I do see potential issues if the user abandons the form after upload.)5 Replies
you can prevent the file moving with this
->moveFiles()
on the FileUpload
https://filamentphp.com/docs/3.x/forms/fields/file-upload#moving-files-instead-of-copying-when-the-form-is-submittedOh, I spent some time on the doc but missed it. Thanks a lot, will have a look
So, I have tested and indeed it is much faster.
However, adding
moveFiles
always set the file to visibility private
even when ->visibility('public')
is set.What do you mean? There is no private/public per file. It depends on your disk.
On S3 buckets there is a visibility per file. From my tests earlier:
https://filamentphp.com/docs/3.x/forms/fields/file-upload#moving-files-instead-of-copying-when-the-form-is-submitted
I think you are looking for the ->moveFiles()
Method