* [FIX] Wrong behavior when viewing PDF files. Thanks to @m-shirokov for the notice. Closes #1501

* [MOD] Minor code tweaks

Signed-off-by: Rubén D <nuxsmin@syspass.org>
This commit is contained in:
Rubén D
2019-12-16 00:40:02 +01:00
parent 54e84f17cf
commit a299760683
6 changed files with 47 additions and 37 deletions

View File

@@ -153,21 +153,23 @@ final class AccountFileController extends ControllerBase implements CrudControll
);
$response = $this->router->response();
$response->header('Cache-Control', 'max-age=60, must-revalidate');
$response->header('Content-length', $fileData->getSize());
$response->header('Content-type', $fileData->getType());
$response->header('Content-Length', $fileData->getSize());
$response->header('Content-Type', $fileData->getType());
$response->header('Content-Description', ' sysPass file');
$response->header('Content-transfer-encoding', 'binary');
$response->header('Content-Transfer-Encoding', 'binary');
$response->header('Accept-Ranges', 'bytes');
$type = strtolower($fileData->getType());
if ($type === 'application/pdf') {
$response->header('Content-Disposition', 'inline; filename="' . $fileData->getName() . '"');
$disposition = sprintf('inline; filename="%s"', $fileData->getName());
} else {
$disposition = sprintf('attachment; filename="%s"', $fileData->getName());
$response->header('Set-Cookie', 'fileDownload=true; path=/');
$response->header('Content-Disposition', 'attachment; filename="' . $fileData->getName() . '"');
}
$response->header('Content-Disposition', $disposition);
$response->body($fileData->getContent());
$response->send(true);
} catch (Exception $e) {