How can I use a resource to write line by line but still use Laravel's built in Storage?
Storage::put('file.xml', $resource);
But what would $resource be here?
$resource is your data that you prepare to write to disk by code.
If you want to write the file with a loop you must use the Storage::append($file_name, $data);
as wrote before by ljubadr
I wrote $data but you can use any name you want for a variable inside a loop.
Per Laravel 5.3 documentation, look into Automatic Streaming
If you would like Laravel to automatically manage streaming a given file to your storage location, you may use the
putFile
orputFileAs
method. This method accepts either aIlluminate\Http\File
orIlluminate\Http\UploadedFile
instance and will automatically stream the file to your desire location:
You can upload file with streaming like this
$file = $request->file('file');$path = \Storage::putFile('photos', $file);
Where your form input is
<input type="file" name="file">