View PDF files in the browser (#51)

Co-authored-by: Paulo Sergio Klaus <code@pauloklaus.com.br>
This commit is contained in:
Paulo K
2020-03-06 11:11:56 -03:00
committed by GitHub
parent 46168368af
commit f29620d9cd

View File

@@ -65,13 +65,21 @@ class DownloadController
// @codeCoverageIgnoreEnd
});
$contentDisposition = HeaderUtils::DISPOSITION_ATTACHMENT;
$contentType = 'application/octet-stream';
if (pathinfo($file['filename'], PATHINFO_EXTENSION) == 'pdf') {
$contentDisposition = HeaderUtils::DISPOSITION_INLINE;
$contentType = 'application/pdf';
}
$streamedResponse->headers->set(
'Content-Disposition',
HeaderUtils::makeDisposition(HeaderUtils::DISPOSITION_ATTACHMENT, $file['filename'], 'file')
$contentDisposition
);
$streamedResponse->headers->set(
'Content-Type',
'application/octet-stream'
$contentType
);
$streamedResponse->headers->set(
'Content-Transfer-Encoding',