StreamResponse class |
Now we don't have a way to handle stream response data.
So, for example, we can't write clean code for outputting CSV file directly from the database data without loading all the records in the memory. See the following articles: https://makitweb.com/how-to-export-data-...igniter-4/ https://onlinewebtutorblog.com/codeignit...-tutorial/
The concept of the framework is that we first collect all the data and then send it. The implementation of the StreamResponce class will need to follow the same concept.
It seems to me that it would be easier to modify ResponseTrait::download() to work with the resource.
ResponseTrait::download() returns DownloadResponse.
The StreamResponse would be similar to the DownloadResponse.
DowloadResponse is specialized for file downloads.
It requires a file to stream output. See the sendBodyByFilePath() method. For example, StreamResponse will be able to output a csv file from the database data without creating a file and without getting all the data in memory. |
Welcome Guest, Not a member yet? Register Sign In |