Working on a project for a customer using Laravel 5.8, I found that when uploading files to S3 using Laravel’s Fly System, that the uploads were failing after a certain size.
The error back was a validation error mentioning the file was unable to be uploaded.
To troubleshoot this, there were a few things I did:
- Ensured my PHP.INI settings were allowing uploads high enough. I found that PHP.INI only allows 2M by default, so I increased this limit to 20M. I also increased the max post time to 300.
- I found out that Amazon S3 doesn’t like files over 5 MB uploading in one go, instead you need to stream it through
Streaming the files
My solution was to have the file upload to the server first, and once it is uploaded, it is streamed from the server to S3.