How do I upload big (video) files in streams to AWS S3 with Laravel 5 and filesystem?


I want to upload a big video file to my AWS S3 bucket. After a good deal of hours, I finally managed to configure my php.ini and nginx.conf files, so they allowed bigger files.

But then I got a "Fatal Error: Allowed Memory Size of XXXXXXXXXX Bytes Exhausted". After some time I found out larger files should be uploaded with streams using fopen(),fwrite(), and fclose().

Since I’m using Laravel 5, the filesystem takes care of much of this. Except that I can’t get it to work.

My current ResourceController@store looks like this:

But now I get this long error:

CouldNotCreateChecksumException in SignatureV4.php line 148:

A sha256 checksum could not be calculated for the provided upload body, because it was not seekable. To prevent this error you can either 1) include the ContentMD5 or ContentSHA256 parameters with your request, 2) use a seekable stream for the body, or 3) wrap the non-seekable stream in a GuzzleHttp\Stream\CachingStream object. You should be careful though and remember that the CachingStream utilizes PHP temp streams. This means that the stream will be temporarily stored on the local disk.

So I am currently completely lost. I can’t figure out if I’m even on the right track. Here are the resource I try to make sense of:

And just to confuse me even more, there seems to be another way to upload large files other than streams: The so called “multipart” upload. I actually thought that was what the streams where all about…

What is the difference?


the streaming part applies to downloads.

for uploads you need to know the content size. for large files multipart uploads are the way to go.

Leave a Reply