Remove the need for a TemporaryDirectory when copying media #2638
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Background
When using the media library pro package (livewire) to upload files directly to AWS S3 the process is like this:
When the submit button is pressed to save the Media item the following happens:
Problem: Large Files
We will be uploading large files to our AWS S3 (2-4 files about .8-1GB each). The current setup using the media library package means there is a whole extra download and upload step which makes this whole scenario take way more time than it needs to.
Solution
To remove the need for this extra copy step I propose these changes to the way media library items are copied and moved.
If the media item is on a remote file storage disk and is moving to the same file storage disk then we will use the internal
Storage::move()
functionality with that disk. This is much faster than streaming because it uses the file storage systems internal move/copy functionalityIf the files are moving between two separate filesystems then we will stream the file directly from one disk to the new disk without saving the file to the laravel server first.