mirror of
https://github.com/filegator/filegator.git
synced 2025-07-31 20:30:31 +02:00
show filesize and remaining time on download (#181)
* show filesize on download
This commit is contained in:
@@ -91,7 +91,12 @@ class DownloadController
|
||||
'Content-Transfer-Encoding',
|
||||
'binary'
|
||||
);
|
||||
|
||||
if (isset($file['filesize'])) {
|
||||
$streamedResponse->headers->set(
|
||||
'Content-Length',
|
||||
$file['filesize']
|
||||
);
|
||||
}
|
||||
// @codeCoverageIgnoreStart
|
||||
if (APP_ENV == 'development') {
|
||||
$streamedResponse->headers->set(
|
||||
@@ -137,11 +142,11 @@ class DownloadController
|
||||
public function batchDownloadStart(Request $request, StreamedResponse $streamedResponse, TmpfsInterface $tmpfs)
|
||||
{
|
||||
$uniqid = (string) preg_replace('/[^0-9a-zA-Z_]/', '', (string) $request->input('uniqid'));
|
||||
$file = $tmpfs->readStream($uniqid);
|
||||
|
||||
$streamedResponse->setCallback(function () use ($tmpfs, $uniqid) {
|
||||
$streamedResponse->setCallback(function () use ($file, $tmpfs, $uniqid) {
|
||||
// @codeCoverageIgnoreStart
|
||||
set_time_limit(0);
|
||||
$file = $tmpfs->readStream($uniqid);
|
||||
if ($file['stream']) {
|
||||
while (! feof($file['stream'])) {
|
||||
echo fread($file['stream'], 1024 * 8);
|
||||
@@ -170,7 +175,12 @@ class DownloadController
|
||||
'Content-Transfer-Encoding',
|
||||
'binary'
|
||||
);
|
||||
|
||||
if (isset($file['filesize'])) {
|
||||
$streamedResponse->headers->set(
|
||||
'Content-Length',
|
||||
$file['filesize']
|
||||
);
|
||||
}
|
||||
// close session so we can continue streaming, note: dev is single-threaded
|
||||
$this->session->save();
|
||||
|
||||
|
Reference in New Issue
Block a user