/**
  * @param FileInterface $file
  * @return bool
  * @throws FileExtensionNotAllowedException
  */
 public function filter(FileInterface $file)
 {
     $fileExtension = $file->getExtension();
     if (in_array(strtolower($fileExtension), $this->allowedExtensions)) {
         return true;
     } else {
         throw new FileExtensionNotAllowedException("File Extension Not Allowed: " . $fileExtension, $file);
     }
 }
Beispiel #2
0
 public function publish(FileInterface $file)
 {
     $fileType = $file->getExtension();
     $fileUploadLink = $file->getPath();
     $fileName = $file->getNameKey() . "." . $fileType;
     if ($file instanceof Image) {
         if ($file->isProcessed()) {
             $size = $file->getImageSize();
             $folder = $size->getWidth() . 'x' . $size->getHeight();
         } else {
             $folder = "original";
         }
     } else {
         $folder = "files";
     }
     $this->s3Client->putObject(array('Bucket' => $this->bucket, 'Key' => $this->url . $this->subfolder . $folder . '/' . $fileName, 'Body' => file_get_contents($fileUploadLink), 'ACL' => 'public-read', 'ContentType' => $file->getType()));
 }