find a better mimetype by using file() and the extension

This commit is contained in:
Uwe Steinmann 2022-11-09 15:14:38 +01:00
parent 5438d95eb5
commit b9311ff1e7

View File

@ -663,14 +663,17 @@ class HTTP_WebDAV_Server_SeedDMS extends HTTP_WebDAV_Server
$tmp = explode(';', $mimetype);
$mimetype = $tmp[0];
$lastDotIndex = strrpos($name, ".");
if($lastDotIndex === false) $fileType = ".";
else $fileType = substr($name, $lastDotIndex);
switch($mimetype) {
case 'application/pdf';
case 'application/pdf':
$fileType = ".pdf";
break;
default:
$lastDotIndex = strrpos($name, ".");
if($lastDotIndex === false) $fileType = ".";
else $fileType = substr($name, $lastDotIndex);
case 'text/plain':
if($fileType == '.md')
$mimetype = 'text/markdown';
break;
}
if($this->logger)
$this->logger->log('PUT: file is of type '.$mimetype, PEAR_LOG_INFO);
@ -698,7 +701,7 @@ class HTTP_WebDAV_Server_SeedDMS extends HTTP_WebDAV_Server
unlink($tmpFile);
return "403 Forbidden";
} else {
/* Check if the new version iѕ identical to the current version.
/* Check if the new version is identical to the current version.
* In that case just update the modification date
*/
$lc = $document->getLatestContent();