/** * @CSRFExemption * @IsAdminExemption * @IsSubAdminExemption * @Ajax * @API */ public function download() { // we no longer need the session to be kept open session_write_close(); $fileId = $this->params('fileId'); $userId = $this->api->getUserId(); try { $track = $this->trackBusinessLayer->findByFileId($fileId, $userId); } catch (DoesNotExistException $e) { $r = new Response(); $r->setStatus(Http::STATUS_NOT_FOUND); return $r; } /** @var $view \OC\Files\View */ $view = $this->api->getView(); $path = $view->getPath($track->getFileId()); $mime = $view->getMimeType($path); $content = $view->file_get_contents($path); return new FileResponse(array('mimetype' => $mime, 'content' => $content)); }
protected function play() { $userId = $this->ampacheUser->getUserId(); $trackId = $this->params('filter'); try { $track = $this->trackMapper->find($trackId, $userId); } catch (DoesNotExistException $e) { $r = new Response(); $r->setStatus(Http::STATUS_NOT_FOUND); return $r; } $files = $this->rootFolder->getById($track->getFileId()); if (count($files) === 1) { return new FileResponse($files[0]); } else { $r = new Response(); $r->setStatus(Http::STATUS_NOT_FOUND); return $r; } }