Esempio n. 1
0
 /**
  * Get the size in bytes.
  */
 public function size() : int
 {
     if (!$this->exists()) {
         return 0;
     }
     return $this->disk->size($this->path);
 }
Esempio n. 2
0
 /**
  * Get Size
  *
  * @param string $filename Path File
  *
  * @return bool
  */
 public function size($filename)
 {
     try {
         return intval($this->storage->size($filename));
     } catch (\Exception $e) {
         return 0;
     }
 }
Esempio n. 3
0
 /**
  * Build files and directory collection for the current directory.
  *
  * @return \Illuminate\Database\Eloquent\Collection
  */
 protected function buildFileAndDirectoryListing()
 {
     $collection = new Collection();
     $files = $this->scanFiles($this->currentDir);
     $thumbnails = $this->buildThumbnails($files);
     $directories = $this->scanDirectory($this->currentDir);
     if ($this->getRootDir() != $this->currentDir) {
         $back_directory = implode('/', explode('/', $this->currentDir, -1));
         $item = [];
         $item['thumbnail'] = '';
         $item['filename'] = '...';
         $item['size'] = '';
         $item['type'] = 'back';
         $item['icon'] = 'fa-reply';
         $item['path'] = $this->currentDir;
         $item['url'] = '?folder=' . $back_directory;
         $item['delete'] = currentUser()->can('media.delete');
         $item['select'] = currentUser()->can('media.view');
         $collection->add($item);
     }
     foreach ($directories as $directory) {
         $directory_name = explode('/', $directory);
         $directory_name = array_pop($directory_name);
         $item = [];
         $item['thumbnail'] = '';
         $item['filename'] = $directory_name;
         $item['path'] = $directory;
         $item['size'] = '';
         $item['type'] = 'directory';
         $item['icon'] = 'fa-folder';
         $item['url'] = '?folder=' . $directory;
         $item['delete'] = currentUser()->can('media.delete');
         $item['select'] = currentUser()->can('media.view');
         $collection->add($item);
     }
     foreach ($files as $path) {
         $item = [];
         $parts = explode('/', $path);
         $filename = array_pop($parts);
         $size = $this->storage->size($path);
         $icon = file_ext_to_icon(File::extension($path));
         $item['type'] = 'file';
         $item['icon'] = $icon;
         $item['thumbnail'] = '';
         if (file_can_have_thumbnail($path)) {
             $item['type'] = 'image';
             $item['icon'] = 'fa-image';
             $item['thumbnail'] = $thumbnails[$path];
         }
         $item['filename'] = $filename;
         $item['size'] = $size;
         $item['url'] = preg_replace("/^public/", '', $path);
         $item['path'] = $path;
         $item['delete'] = currentUser()->can('media.delete');
         $item['select'] = currentUser()->can('media.view');
         $collection->add($item);
     }
     return $collection;
 }
Esempio n. 4
0
 /**
  * Get the file size of a given file.
  *
  * @param  string $path
  *
  * @return int
  */
 public function size($path)
 {
     $path = $this->getPathPrefix($path);
     return $this->drive->size($path);
 }