'image/jpeg', 'gif' => 'image/gif', 'png' => 'image/png', // groupware 'ics' => 'text/calendar', 'vcf' => 'text/vcard', // text 'txt' => 'text/plain', ]; /** * Initializes the plugin * * @param DAV\Server $server * @return void */ function initialize(DAV\Server $server) { // Using a relatively low priority (200) to allow other extensions // to set the content-type first. $server->on('propFind', [$this, 'propFind'], 200); } /** * Our PROPFIND handler * * Here we set a contenttype, if the node didn't already have one. * * @param PropFind $propFind * @param INode $node * @return void */ function propFind(PropFind $propFind, INode $node) { $propFind->handle('{DAV:}getcontenttype', function() use ($propFind) { list(, $fileName) = URLUtil::splitPath($propFind->getPath()); return $this->getContentType($fileName); }); } /** * Simple method to return the contenttype * * @param string $fileName * @return string */ protected function getContentType($fileName) { // Just grabbing the extension $extension = strtolower(substr($fileName, strrpos($fileName, '.') + 1)); if (isset($this->extensionMap[$extension])) { return $this->extensionMap[$extension]; } return 'application/octet-stream'; } }