Sending multipart response for downloads in Zend Framework
Posted
by takeshin
on Stack Overflow
See other posts from Stack Overflow
or by takeshin
Published on 2010-04-25T13:14:28Z
Indexed on
2010/04/25
13:23 UTC
Read the original article
Hit count: 431
I'm sending files in action helper for downloads (in parts if needed) like this:
...
$response->sendHeaders();
$chunksize = 1 * (1024 * 1024);
$bytesSent = 0;
if ($httpRange) {
fseek($file, $range);
}
while(!feof($file) &&
(!connection_aborted() &&
($bytesSent < $newLength))
) {
$buffer = fread($file, $chunksize);
// $response->appendBody($buffer); // this would be better
print($buffer);
flush();
$bytesSent += strlen($buffer);
}
fclose($file);
I suspect that better way would be to make use of $response
object instead of print
.
Which is the recommended way to send big response objects using Zend Framework?
© Stack Overflow or respective owner