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
Grégoire
GrégoireOP7d ago
Oh, 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.
Dennis Koch
Dennis Koch7d ago
What do you mean? There is no private/public per file. It depends on your disk.
Grégoire
GrégoireOP7d ago
On S3 buckets there is a visibility per file. From my tests earlier:
// The video file has a `private` visibility no matter what you set in the `visibility` method.
FileUpload::make('video_path')
->disk(config('filesystems.default')) // DigitalOcean S3 Space
->visibility('public')
->directory('videos')
->moveFiles();

// Removing the `moveFiles` method will make the visibility work as expected but is slow on save.
FileUpload::make('video_path')
->disk(config('filesystems.default')) // DigitalOcean S3 Space
->visibility('public')
->directory('videos');
// The video file has a `private` visibility no matter what you set in the `visibility` method.
FileUpload::make('video_path')
->disk(config('filesystems.default')) // DigitalOcean S3 Space
->visibility('public')
->directory('videos')
->moveFiles();

// Removing the `moveFiles` method will make the visibility work as expected but is slow on save.
FileUpload::make('video_path')
->disk(config('filesystems.default')) // DigitalOcean S3 Space
->visibility('public')
->directory('videos');

Did you find this page helpful?