From 6fd11b630b64e18ba5a69950b75a611ab957a76f Mon Sep 17 00:00:00 2001 From: aina-esokia Date: Wed, 21 Feb 2018 11:43:53 +0400 Subject: [PATCH] allow to specify a filename on permalink usage --- lib/Alchemy/Phrasea/Controller/AbstractDelivery.php | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/lib/Alchemy/Phrasea/Controller/AbstractDelivery.php b/lib/Alchemy/Phrasea/Controller/AbstractDelivery.php index edce950bd1..95f57fd220 100644 --- a/lib/Alchemy/Phrasea/Controller/AbstractDelivery.php +++ b/lib/Alchemy/Phrasea/Controller/AbstractDelivery.php @@ -34,11 +34,14 @@ abstract class AbstractDelivery { $mediaSubdefinition = $record->get_subdef($subdef); + $filename = $request->get("filename") ?: $mediaSubdefinition->get_file(); + $pathOut = $this->tamperProofSubDefinition($mediaSubdefinition, $watermark, $stamp); $disposition = $request->query->get('download') ? DeliverDataInterface::DISPOSITION_ATTACHMENT : DeliverDataInterface::DISPOSITION_INLINE; - $response = $this->deliverFile($pathOut, $mediaSubdefinition->get_file(), $disposition, $mediaSubdefinition->get_mime()); + // nb: $filename will be sanitized, no need to do it here + $response = $this->deliverFile($pathOut, $filename, $disposition, $mediaSubdefinition->get_mime()); if (in_array($subdef, array('document', 'preview'))) { $response->setPrivate();