Exemplo n.º 1
0
 /**
  * Guess MIME Type based on the path of the file and it's content.
  *
  * @param string $path
  * @param string|resource $content
  *
  * @return string|null MIME Type or NULL if no extension detected
  */
 public static function guessMimeType($path, $content)
 {
     $mimeType = MimeType::detectByContent($content);
     if (!(empty($mimeType) || in_array($mimeType, ['application/x-empty', 'text/plain', 'text/x-asm']))) {
         return $mimeType;
     }
     return MimeType::detectByFilename($path);
 }
Exemplo n.º 2
0
 /**
  * @inheritdoc
  */
 public function getMimetype($path)
 {
     if (!($metadata = $this->getMetadata($path))) {
         return false;
     }
     $metadata['mimetype'] = MimeType::detectByFilename($path);
     return $metadata;
 }
Exemplo n.º 3
0
 /**
  * @inheritdoc
  */
 public function getMimetype($path)
 {
     $location = $this->applyPathPrefix($path);
     $finfo = new Finfo(FILEINFO_MIME_TYPE);
     $mimetype = $finfo->file($location);
     if (in_array($mimetype, ['application/octet-stream', 'inode/x-empty'])) {
         $mimetype = Util\MimeType::detectByFilename($location);
     }
     return ['mimetype' => $mimetype];
 }