public function addTorrentFromFile($path)
 {
     $oldFile = realpath($path);
     $newFile = FileUtils::encodeFilename($oldFile);
     rename($oldFile, $newFile);
     $result = $this->service->call('addTorrentFromFile', ['file' => $newFile]);
     unlink($newFile);
     return $result;
 }
예제 #2
0
 public function remove($path)
 {
     if (!$this->isDeletable($path)) {
         return false;
     }
     Sharing::deleteByPathRecursively($this->getRelativePath($path), $this->ownerId);
     if (is_file($path)) {
         return unlink($path);
     } elseif ($path != $this->rootDir) {
         return FileUtils::rrmdir($path);
     }
     return false;
 }
예제 #3
0
 public function getSize()
 {
     if ($this->size === null) {
         if ($this->isFile()) {
             $this->size = filesize($this->absolutePath);
         } else {
             $this->size = FileUtils::dirsize($this->absolutePath);
         }
     }
     return $this->size;
 }
 protected function displayFile(Request $request, FileManager $fileManager)
 {
     if (!$request->query->has('path')) {
         return $this->abort(400);
     }
     $path = $fileManager->getAbsolutePath($request->query->get('path'));
     if (!is_file($path)) {
         return $this->abort(404);
     }
     $mimeType = FileUtils::getMimeType($path);
     if (!MimeType::isDisplayable($mimeType)) {
         return $this->abort(500, 'error.notDisplayable');
     }
     $relativePath = $fileManager->getRelativePath($path);
     $breadcrumb = self::getBreadcrumb($fileManager, $path, false);
     $name = pathinfo($relativePath, PATHINFO_BASENAME);
     $data = ["name" => $name, "breadcrumb" => $breadcrumb];
     if (MimeType::isText($mimeType)) {
         $data["text"] = file_get_contents($path);
     } elseif (MimeType::isImage($mimeType)) {
         $data["src"] = $relativePath;
     }
     return $this->render($data);
 }