I want to use Storage::put
to write a file. The file is potentially very large (>100MB), so I want to utilise a stream so I don't blindly place everything into memory.
I'm going to be making multiple API requests, and then looping through their results, so the data I'll be getting back isn't an issue, it'll be limited to sensible amounts.
According to the documentation, I need to use:
Storage::put('file.xml', $resource);
But what would $resource
be here?
Traditionally when writing files using PHP I have done it with a combination of fopen
, fwrite
and fclose
in order to write 'line by line'. I'm building the file up by looping through various Collections and utlising various APIs as I go, so $resource
is NOT a file pointer or file reference as is talked about elsewhere in the documentation.
So, how can I write line by line using a stream and Laravel's Storage
?
putFileAs
. – Starlight