File tree Expand file tree Collapse file tree 1 file changed +6
-8
lines changed
Expand file tree Collapse file tree 1 file changed +6
-8
lines changed Original file line number Diff line number Diff line change @@ -258,27 +258,25 @@ public function download(?string $filename = null): int
258258 HttpHeaders::forFileDownload ($ filename , 'text/csv ' );
259259 }
260260
261- $ bomOutputLength = 0 ;
261+ $ bytes = 0 ;
262+ $ output = new SplFileObject ('php://output ' , 'wb ' );
262263 if (null !== $ this ->output_bom ) {
263- echo $ this ->output_bom ->value ;
264- $ bomOutputLength = $ this ->output_bom ->length ();
264+ $ bytes += $ output ->fwrite ($ this ->output_bom ->value );
265265 }
266266
267267 $ this ->getInputBOM ();
268268 $ this ->document ->rewind ();
269269 $ this ->document ->setFlags (0 );
270270 $ this ->is_input_bom_included || -1 < $ this ->document ->fseek ($ this ->input_bom ?->length() ?? 0 ) || throw new RuntimeException ('Unable to seek the document. ' );
271271
272- $ documentOutputLength = 0 ;
273272 while (!$ this ->document ->eof ()) {
274273 $ chunk = $ this ->document ->fread (8192 );
275274 false !== $ chunk || throw new RuntimeException ('Unable to read the document. ' );
276- $ documentOutputLength += strlen ($ chunk );
277- echo $ chunk ;
278- flush ();
275+ $ bytes += $ output ->fwrite ($ chunk );
276+ $ output ->fflush ();
279277 }
280278
281- return $ bomOutputLength + $ documentOutputLength ;
279+ return $ bytes ;
282280 }
283281
284282 /**
You can’t perform that action at this time.
0 commit comments