From 9a54a234bae200d66b95b09208a37bb4d62173a7 Mon Sep 17 00:00:00 2001 From: jtfnetoo Date: Wed, 1 Feb 2023 15:23:36 -0400 Subject: [PATCH] =?UTF-8?q?Fazendo=20append=20da=20extens=C3=A3o=20do=20fo?= =?UTF-8?q?rmato=20ao=20filename.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/app/Services/JasperServerRequestService.php | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/src/app/Services/JasperServerRequestService.php b/src/app/Services/JasperServerRequestService.php index e60b11f..62ecb89 100644 --- a/src/app/Services/JasperServerRequestService.php +++ b/src/app/Services/JasperServerRequestService.php @@ -261,9 +261,11 @@ class JasperServerRequestService implements JasperServerRequestServiceContract private function setHeader(string $report, ?string $filename = null) { if (!$filename) { - $filename = uniqid() . '.' . $this->format; + $filename = uniqid(); } + $filename = $this->appendFormatExtension($filename); + header('Cache-Control: must-revalidate'); header('Pragma: public'); header('Content-Description: File Transfer'); @@ -272,4 +274,13 @@ class JasperServerRequestService implements JasperServerRequestServiceContract header('Content-Length: ' . strlen($report)); header('Content-Type: ' . ReportFormatEnum::getMimeType($this->format)); } + + /** + * @param string $filename + * @return string + */ + private function appendFormatExtension(string $filename): string + { + return $filename . '.' . $this->format; + } }