Merge pull request #3725 from nextcloud/issue-fac-55-mimetype-detection-on-public-uploads
Fix mimetype detection on public uploads for the workflow engine
This commit is contained in:
commit
abecae2388
|
@ -48,6 +48,8 @@ class Application extends \OCP\AppFramework\App {
|
|||
]);
|
||||
|
||||
script('core', [
|
||||
'files/fileinfo',
|
||||
'files/client',
|
||||
'oc-backbone-webdav',
|
||||
'systemtags/systemtags',
|
||||
'systemtags/systemtagmodel',
|
||||
|
|
|
@ -76,13 +76,22 @@ class FileMimeType extends AbstractStringCheck {
|
|||
return $this->mimeType[$this->storage->getId()][$this->path];
|
||||
}
|
||||
|
||||
$this->mimeType[$this->storage->getId()][$this->path] = '';
|
||||
if ($this->isWebDAVRequest()) {
|
||||
if ($this->request->getMethod() === 'PUT') {
|
||||
$path = $this->request->getPathInfo();
|
||||
$this->mimeType[$this->storage->getId()][$this->path] = $this->mimeTypeDetector->detectPath($path);
|
||||
return $this->mimeType[$this->storage->getId()][$this->path];
|
||||
}
|
||||
} else if ($this->isPublicWebDAVRequest()) {
|
||||
if ($this->request->getMethod() === 'PUT') {
|
||||
$path = $this->request->getPathInfo();
|
||||
if (strpos($path, '/webdav/') === 0) {
|
||||
$path = substr($path, strlen('/webdav'));
|
||||
}
|
||||
$path = $this->path . $path;
|
||||
$this->mimeType[$this->storage->getId()][$path] = $this->mimeTypeDetector->detectPath($path);
|
||||
return $this->mimeType[$this->storage->getId()][$path];
|
||||
}
|
||||
}
|
||||
|
||||
if (in_array($this->request->getMethod(), ['POST', 'PUT'])) {
|
||||
|
@ -159,4 +168,14 @@ class FileMimeType extends AbstractStringCheck {
|
|||
strpos($this->request->getPathInfo(), '/dav/files/') === 0
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
protected function isPublicWebDAVRequest() {
|
||||
return substr($this->request->getScriptName(), 0 - strlen('/public.php')) === '/public.php' && (
|
||||
$this->request->getPathInfo() === '/webdav' ||
|
||||
strpos($this->request->getPathInfo(), '/webdav/') === 0
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue