/** * @return string|null */ public function getFileId() { if ($this->info->getId()) { $instanceId = OC_Util::getInstanceId(); $id = sprintf('%08d', $this->info->getId()); return $id . $instanceId; } return null; }
/** * Create a new file search result * @param FileInfo $data file data given by provider */ public function __construct(FileInfo $data) { $path = $this->getRelativePath($data->getPath()); $info = pathinfo($path); $this->id = $data->getId(); $this->name = $info['basename']; $this->link = \OCP\Util::linkTo('files', 'index.php', array('dir' => $info['dirname'], 'file' => $info['basename'])); $this->permissions = $data->getPermissions(); $this->path = $path; $this->size = $data->getSize(); $this->modified = $data->getMtime(); $this->mime_type = $data->getMimetype(); }
/** * Create a new file search result * @param FileInfo $data file data given by provider */ public function __construct(FileInfo $data) { $path = $this->getRelativePath($data->getPath()); $info = pathinfo($path); $this->id = $data->getId(); $this->name = $info['basename']; $this->link = \OC::$server->getURLGenerator()->linkToRoute('files.view.index', ['dir' => $info['dirname'], 'scrollto' => $info['basename']]); $this->permissions = $data->getPermissions(); $this->path = $path; $this->size = $data->getSize(); $this->modified = $data->getMtime(); $this->mime = $data->getMimetype(); }
/** * Sends the preview, including the headers to client which requested it * * @param null|string $mimeTypeForHeaders the media type to use when sending back the reply * * @throws NotFoundException */ public function showPreview($mimeTypeForHeaders = null) { // Check if file is valid if ($this->isFileValid() === false) { throw new NotFoundException('File not found.'); } if ($cachedPath = $this->isCached($this->info->getId())) { header('Content-Type: ' . $this->info->getMimetype()); $this->userView->readfile($cachedPath); return; } if (is_null($this->preview)) { $this->getPreview(); } if ($this->preview instanceof \OCP\IImage) { if ($this->preview->valid()) { \OCP\Response::enableCaching(3600 * 24); // 24 hours } else { $this->getMimeIcon(); } $this->preview->show($mimeTypeForHeaders); } }
/** * @return integer */ public function getInternalFileId() { return $this->info->getId(); }