getExtensionForMimeType() public static method

Returns the correct extension for a mime type.
public static getExtensionForMimeType ( string $mimeType ) : string
$mimeType string
return string
Example #1
0
 public function tempOriginal(Image $image)
 {
     // Recreate original filename
     $tempOriginalPath = tempnam(sys_get_temp_dir(), null);
     $originalPath = sprintf('%s-%s.%s', $image->getKey(), $this->generateHash($image), Mime::getExtensionForMimeType($image->mime_type));
     // Download file
     $this->ftp->fget($tempOriginalPath, $originalPath, FtpClient::ASCII);
     return new File($tempOriginalPath);
 }
Example #2
0
 /**
  * Tells the driver to prepare a copy of the original image locally.
  *
  * @param Image $image
  * @return File
  */
 public function tempOriginal(Image $image)
 {
     // Recreate original filename
     $tempOriginalPath = tempnam(sys_get_temp_dir(), null);
     $originalPath = sprintf('%s-%s.%s', $image->getKey(), $this->generateHash($image), Mime::getExtensionForMimeType($image->mime_type));
     // Download file
     $this->s3->getObject(array('Bucket' => $this->awsBucket, 'Key' => $originalPath, 'SaveAs' => $tempOriginalPath));
     return new File($tempOriginalPath);
 }
Example #3
0
 /**
  * @param Image $image
  * @param array $filters
  * @return string
  */
 protected function generateFileName(Image $image, array $filters = [])
 {
     return sprintf('%s-%s.%s', $image->getKey(), $this->generateHash($image, $filters), Mime::getExtensionForMimeType($image->mime_type));
 }
Example #4
0
 /**
  * Tells the driver to prepare a copy of the original image locally.
  *
  * @param Image $image
  * @return File
  * @throws \Exception
  */
 public function tempOriginal(Image $image)
 {
     $originalPath = sprintf('%s/%s-%s.%s', $this->root, $image->getKey(), $this->generateHash($image), Mime::getExtensionForMimeType($image->mime_type));
     $tempOriginalPath = tempnam(sys_get_temp_dir(), null);
     if (!copy($originalPath, $tempOriginalPath)) {
         throw new \Exception('Imager couldn\'t copy the original image to the temporary location');
     }
     return new File($tempOriginalPath);
 }