view = $view; } public function enable() { $this->enabled = true; } /** * This initializes the plugin. * * @param \Sabre\DAV\Server $server Sabre server * * @return void * @throws MethodNotAllowed */ public function initialize(\Sabre\DAV\Server $server) { $server->on('beforeMethod:*', [$this, 'beforeMethod'], 999); $this->enabled = false; } public function beforeMethod(RequestInterface $request, ResponseInterface $response) { if (!$this->enabled) { return; } if ($request->getMethod() !== 'PUT') { throw new MethodNotAllowed('Only PUT is allowed on files drop'); } $path = explode('/', $request->getPath()); $path = array_pop($path); $newName = \OC_Helper::buildNotExistingFileNameForView('/', $path, $this->view); $url = $request->getBaseUrl() . $newName; $request->setUrl($url); } }