/**
  * @param NewImageEvent $event
  */
 private function transferImageFiles(NewImageEvent $event)
 {
     $preProcessed = $this->imagePreProcessor->preProcess($event->image());
     /** @var ImagickContract $imagick */
     foreach ($preProcessed as $imagick) {
         $this->publicFilesystem->getDriver()->put("image/{$imagick->getFilename()}", $imagick->getImageBlob(), self::fileConfig());
     }
 }
Example #2
0
 /**
  * @param      $currentFile
  * @param      $newFile
  * @param bool $isFolder
  *
  * @return bool|string
  */
 public function move($currentFile, $newFile, $isFolder = false)
 {
     if ($isFolder) {
         if ($newFile == $currentFile) {
             return 'Please select another folder to move this folder into';
         }
         if (starts_with($newFile, $currentFile)) {
             return 'You can not move this folder inside of itself';
         }
     }
     if ($this->disk->exists($newFile)) {
         return 'File already exists.';
     }
     return $this->disk->getDriver()->rename($currentFile, $newFile);
 }
 public function makeUploadedImageThumbnail(Image $image)
 {
     // Download the previously saved image and make a thumbnail of it
     $contents = $this->storage->get($image->directory . '/' . $image->filename);
     if (!$contents) {
         return false;
     }
     // Temp file to store the downloaded image
     $tmpFile = $this->makeTmpFile();
     // Save downloaded image locally
     file_put_contents($tmpFile->getPathname(), $contents);
     // and set it as the working image
     $this->file = $tmpFile;
     // Make a smaller version for showing on site
     $thumbFile = $this->makeThumbnailImage(100, 100);
     // Copy to S3
     $this->storage->getDriver()->put($image->directory . 'thumbs/' . $image->filename, file_get_contents($thumbFile->getPathname()), ['StorageClass' => 'REDUCED_REDUNDANCY']);
     // Delete the local temp thumb
     unlink($thumbFile->getPathname());
     // Update the image so it has a thumb
     $image->thumb = true;
     $image->save();
     return true;
 }
Example #4
0
 /**
  * Get the Flysystem driver.
  *
  * @return \League\Flysystem\FilesystemInterface 
  * @static 
  */
 public static function getDriver()
 {
     return \Illuminate\Filesystem\FilesystemAdapter::getDriver();
 }