Fixed ch15966 - attempts to download extremely large files (Backups) exhausts all memory #9276
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.
Laravel has a
Storage::download()
method which we use, but that breaks pretty hard on large enough files (basically, anything bigger than the memory limit, or so). Backups in particular, for customers who have lots of images, can easily exceed that.This adds a new
StorageHelper
Helper class (just a single static method right now) and uses it where it makes sense. Though, see caveats below. I called my methoddownloader
rather thandownload
to make sure we can easily visually distinguish betweenStorage::download()
andStorageHelper::downloader()
.I tested it against local storage and against S3, and it was able to download my 1GB file with ease in all the sections where I made modifications.
Some caveats:
storage/private_uploads
- most frequently usingconfig('app.private_uploads')
. Again, it was already like this already so I figured this isn't any worse.