summaryrefslogtreecommitdiffstats
path: root/apps/dav/lib/Connector
diff options
context:
space:
mode:
authorVincent Petry <pvince81@owncloud.com>2016-06-10 09:55:59 +0200
committerGitHub <noreply@github.com>2016-06-10 09:55:59 +0200
commit543545505d6caa46142a41a074e75f27743c8b02 (patch)
tree5f9ffe8613024eb6012512d99ab8e83c21b001b1 /apps/dav/lib/Connector
parente8a66f8e7d6079c0982e2e377ca9eea7e451acea (diff)
parent1399e87d57e1b91a5d6888021bef310d35f10b4f (diff)
downloadnextcloud-server-543545505d6caa46142a41a074e75f27743c8b02.tar.gz
nextcloud-server-543545505d6caa46142a41a074e75f27743c8b02.zip
Merge pull request #25043 from owncloud/webdav-download-mimetype
DAV now returns file name with Content-Disposition header
Diffstat (limited to 'apps/dav/lib/Connector')
-rw-r--r--apps/dav/lib/Connector/Sabre/FilesPlugin.php23
-rw-r--r--apps/dav/lib/Connector/Sabre/ServerFactory.php1
2 files changed, 23 insertions, 1 deletions
diff --git a/apps/dav/lib/Connector/Sabre/FilesPlugin.php b/apps/dav/lib/Connector/Sabre/FilesPlugin.php
index dc47416cca8..0a2e6713cb4 100644
--- a/apps/dav/lib/Connector/Sabre/FilesPlugin.php
+++ b/apps/dav/lib/Connector/Sabre/FilesPlugin.php
@@ -42,6 +42,7 @@ use \Sabre\HTTP\RequestInterface;
use \Sabre\HTTP\ResponseInterface;
use OCP\Files\StorageNotAvailableException;
use OCP\IConfig;
+use OCP\IRequest;
class FilesPlugin extends ServerPlugin {
@@ -96,19 +97,28 @@ class FilesPlugin extends ServerPlugin {
private $config;
/**
+ * @var IRequest
+ */
+ private $request;
+
+ /**
* @param Tree $tree
* @param View $view
+ * @param IConfig $config
+ * @param IRequest $request
* @param bool $isPublic
* @param bool $downloadAttachment
*/
public function __construct(Tree $tree,
View $view,
IConfig $config,
+ IRequest $request,
$isPublic = false,
$downloadAttachment = true) {
$this->tree = $tree;
$this->fileView = $view;
$this->config = $config;
+ $this->request = $request;
$this->isPublic = $isPublic;
$this->downloadAttachment = $downloadAttachment;
}
@@ -225,7 +235,18 @@ class FilesPlugin extends ServerPlugin {
// adds a 'Content-Disposition: attachment' header
if ($this->downloadAttachment) {
- $response->addHeader('Content-Disposition', 'attachment');
+ $filename = $node->getName();
+ if ($this->request->isUserAgent(
+ [
+ \OC\AppFramework\Http\Request::USER_AGENT_IE,
+ \OC\AppFramework\Http\Request::USER_AGENT_ANDROID_MOBILE_CHROME,
+ \OC\AppFramework\Http\Request::USER_AGENT_FREEBOX,
+ ])) {
+ $response->addHeader('Content-Disposition', 'attachment; filename="' . rawurlencode($filename) . '"');
+ } else {
+ $response->addHeader('Content-Disposition', 'attachment; filename*=UTF-8\'\'' . rawurlencode($filename)
+ . '; filename="' . rawurlencode($filename) . '"');
+ }
}
if ($node instanceof \OCA\DAV\Connector\Sabre\File) {
diff --git a/apps/dav/lib/Connector/Sabre/ServerFactory.php b/apps/dav/lib/Connector/Sabre/ServerFactory.php
index b193bfc76c7..699dd77166e 100644
--- a/apps/dav/lib/Connector/Sabre/ServerFactory.php
+++ b/apps/dav/lib/Connector/Sabre/ServerFactory.php
@@ -144,6 +144,7 @@ class ServerFactory {
$objectTree,
$view,
$this->config,
+ $this->request,
false,
!$this->config->getSystemValue('debug', false)
)