Example #1
0
 /**
  * Generate the thumbnail based on a remote storage engine.
  */
 protected function makeThumbStorage($thumbFile, $thumbPath, $width, $height, $options)
 {
     $tempFile = $this->getLocalTempPath();
     $tempThumb = $this->getLocalTempPath($thumbFile);
     /*
      * Handle a broken source image
      */
     if (!$this->hasFile($this->disk_name)) {
         BrokenImage::copyTo($tempThumb);
     } else {
         $this->copyStorageToLocal($this->getDiskPath(), $tempFile);
         $resizer = Resizer::open($tempFile);
         $resizer->resize($width, $height, $options['mode'], $options['offset']);
         $resizer->save($tempThumb, $options['quality']);
         FileHelper::delete($tempFile);
     }
     /*
      * Publish to storage and clean up
      */
     $this->copyLocalToStorage($tempThumb, $thumbPath);
     FileHelper::delete($tempThumb);
 }
Example #2
0
 /**
  * Delete file contents from storage device.
  */
 protected function deleteFile($fileName = null)
 {
     if (!$fileName) {
         $fileName = $this->disk_name;
     }
     $directory = $this->getStorageDirectory() . $this->getPartitionDirectory();
     FileHelper::delete($directory . $fileName);
     $this->deleteEmptyDirectory($directory);
 }
Example #3
0
 public function deleteThumbs()
 {
     $pattern = 'thumb_' . $this->id . '_';
     $directory = $this->getStorageDirectory() . $this->getPartitionDirectory();
     $allFiles = $this->storageCmd('files', $directory);
     $collection = [];
     foreach ($allFiles as $file) {
         if (starts_with(basename($file), $pattern)) {
             $collection[] = $file;
         }
     }
     /*
      * Delete the collection of files
      */
     if (!empty($collection)) {
         if ($this->isLocalStorage()) {
             FileHelper::delete($collection);
         } else {
             Storage::delete($collection);
         }
     }
 }