summaryrefslogtreecommitdiffstats
path: root/lib/private/Files/Storage
diff options
context:
space:
mode:
authorRobin Appelman <robin@icewind.nl>2017-09-28 14:22:42 +0200
committerRobin Appelman <robin@icewind.nl>2017-09-28 14:22:42 +0200
commitb36dd8b71fb8751b07ef98443d739d0b1cda9c7d (patch)
tree95c994b25a8bcbfdfbbff514ca26607c1677dabe /lib/private/Files/Storage
parent1c2da7d7d38d3bffef1ff2396edab65e9d3370b8 (diff)
downloadnextcloud-server-b36dd8b71fb8751b07ef98443d739d0b1cda9c7d.tar.gz
nextcloud-server-b36dd8b71fb8751b07ef98443d739d0b1cda9c7d.zip
Fallback to filename based detection if the remote dav server doesn't know the mimetype
Signed-off-by: Robin Appelman <robin@icewind.nl>
Diffstat (limited to 'lib/private/Files/Storage')
-rw-r--r--lib/private/Files/Storage/DAV.php26
1 files changed, 17 insertions, 9 deletions
diff --git a/lib/private/Files/Storage/DAV.php b/lib/private/Files/Storage/DAV.php
index 223f270bc45..be23021d8f4 100644
--- a/lib/private/Files/Storage/DAV.php
+++ b/lib/private/Files/Storage/DAV.php
@@ -146,7 +146,7 @@ class DAV extends Common {
}
$proxy = \OC::$server->getConfig()->getSystemValue('proxy', '');
- if($proxy !== '') {
+ if ($proxy !== '') {
$settings['proxy'] = $proxy;
}
@@ -343,11 +343,11 @@ class DAV extends Common {
case 'rb':
try {
$response = $this->httpClientService
- ->newClient()
- ->get($this->createBaseUri() . $this->encodePath($path), [
- 'auth' => [$this->user, $this->password],
- 'stream' => true
- ]);
+ ->newClient()
+ ->get($this->createBaseUri() . $this->encodePath($path), [
+ 'auth' => [$this->user, $this->password],
+ 'stream' => true
+ ]);
} catch (RequestException $e) {
if ($e->getResponse() instanceof ResponseInterface
&& $e->getResponse()->getStatusCode() === 404) {
@@ -590,6 +590,15 @@ class DAV extends Common {
/** {@inheritdoc} */
public function getMimeType($path) {
+ $remoteMimetype = $this->getMimeTypeFromRemote($path);
+ if ($remoteMimetype === 'application/octet-stream') {
+ return \OC::$server->getMimeTypeDetector()->detectPath($path);
+ } else {
+ return $remoteMimetype;
+ }
+ }
+
+ public function getMimeTypeFromRemote($path) {
try {
$response = $this->propfind($path);
if ($response === false) {
@@ -606,12 +615,11 @@ class DAV extends Common {
} elseif (isset($response['{DAV:}getcontenttype'])) {
return $response['{DAV:}getcontenttype'];
} else {
- return false;
+ return 'application/octet-stream';
}
} catch (\Exception $e) {
- $this->convertException($e, $path);
+ return false;
}
- return false;
}
/**