mirror of
https://github.com/nuxsmin/sysPass.git
synced 2026-03-14 20:36:46 +01:00
* [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:
@@ -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) {
|
||||
|
||||
Reference in New Issue
Block a user