From d9db2adfc8b3cb44fed60f56ac6290576daa7688 Mon Sep 17 00:00:00 2001 From: Benjamin Perche Date: Fri, 4 Jul 2014 14:34:30 +0200 Subject: [PATCH] =?UTF-8?q?Add=20filename=20in=20build=20archive=20respons?= =?UTF-8?q?e=20=09modifi=C3=A9:=20=20=20=20=20=20=20=20=20core/lib/Thelia/?= =?UTF-8?q?Core/FileFormat/Archive/ArchiveBuilder/TarArchiveBuilder.php=20?= =?UTF-8?q?=09modifi=C3=A9:=20=20=20=20=20=20=20=20=20core/lib/Thelia/Core?= =?UTF-8?q?/FileFormat/Archive/ArchiveBuilder/ZipArchiveBuilder.php=20=09m?= =?UTF-8?q?odifi=C3=A9:=20=20=20=20=20=20=20=20=20core/lib/Thelia/Core/Fil?= =?UTF-8?q?eFormat/Archive/ArchiveBuilderInterface.php?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../FileFormat/Archive/ArchiveBuilder/TarArchiveBuilder.php | 3 ++- .../FileFormat/Archive/ArchiveBuilder/ZipArchiveBuilder.php | 5 +++-- .../Core/FileFormat/Archive/ArchiveBuilderInterface.php | 4 +++- 3 files changed, 8 insertions(+), 4 deletions(-) diff --git a/core/lib/Thelia/Core/FileFormat/Archive/ArchiveBuilder/TarArchiveBuilder.php b/core/lib/Thelia/Core/FileFormat/Archive/ArchiveBuilder/TarArchiveBuilder.php index 0f2cd67c7..35f9a5d55 100644 --- a/core/lib/Thelia/Core/FileFormat/Archive/ArchiveBuilder/TarArchiveBuilder.php +++ b/core/lib/Thelia/Core/FileFormat/Archive/ArchiveBuilder/TarArchiveBuilder.php @@ -236,7 +236,7 @@ class TarArchiveBuilder extends AbstractArchiveBuilder * * This method return an instance of a Response with the archive as content. */ - public function buildArchiveResponse() + public function buildArchiveResponse($filename) { $this->tar->setMetadata("Generated by Thelia v" . Thelia::THELIA_VERSION); @@ -262,6 +262,7 @@ class TarArchiveBuilder extends AbstractArchiveBuilder 200, [ "Content-Type" => $this->getMimeType(), + "Content-Disposition" => $filename . "." . $this->getExtension(), ] ); } diff --git a/core/lib/Thelia/Core/FileFormat/Archive/ArchiveBuilder/ZipArchiveBuilder.php b/core/lib/Thelia/Core/FileFormat/Archive/ArchiveBuilder/ZipArchiveBuilder.php index fd49b5c87..220cd24e4 100644 --- a/core/lib/Thelia/Core/FileFormat/Archive/ArchiveBuilder/ZipArchiveBuilder.php +++ b/core/lib/Thelia/Core/FileFormat/Archive/ArchiveBuilder/ZipArchiveBuilder.php @@ -302,7 +302,7 @@ class ZipArchiveBuilder extends AbstractArchiveBuilder * * This method return an instance of a Response with the archive as content. */ - public function buildArchiveResponse() + public function buildArchiveResponse($filename) { $this->zip->comment = "Generated by Thelia v" . Thelia::THELIA_VERSION; @@ -331,7 +331,8 @@ class ZipArchiveBuilder extends AbstractArchiveBuilder $content, 200, [ - "Content-Type" => $this->getMimeType() + "Content-Type" => $this->getMimeType(), + "Content-Disposition" => $filename . "." . $this->getExtension(), ] ); } diff --git a/core/lib/Thelia/Core/FileFormat/Archive/ArchiveBuilderInterface.php b/core/lib/Thelia/Core/FileFormat/Archive/ArchiveBuilderInterface.php index ab37760ca..0ff882ae5 100644 --- a/core/lib/Thelia/Core/FileFormat/Archive/ArchiveBuilderInterface.php +++ b/core/lib/Thelia/Core/FileFormat/Archive/ArchiveBuilderInterface.php @@ -76,12 +76,14 @@ interface ArchiveBuilderInterface * This method creates an empty directory */ public function addDirectory($directoryPath); + /** + * @params string $filename * @return \Thelia\Core\HttpFoundation\Response * * This method return an instance of a Response with the archive as content. */ - public function buildArchiveResponse(); + public function buildArchiveResponse($filename); /** * @param string $pathToArchive