Exemple #1
0
 /**
  * Get the mime encoding (e.g. "binary" or "us-ascii" or "utf-8") of the file.
  *
  * @return string
  */
 public function getMIMEEncoding()
 {
     $adapter = $this->file->internalPathname()->localAdapter();
     if ($adapter instanceof MimeAwareAdapterInterface) {
         return $adapter->getMimeEncoding($this->file->internalPathname());
     }
     return Util::executeFunction(function () {
         return finfo_buffer(Util::getFileInfo(), $this->file->getContents(), FILEINFO_MIME_ENCODING);
     }, 'Filicious\\Exception\\PluginException', 0, 'Could not determine mime encoding');
 }
Exemple #2
0
 /**
  * {@inheritdoc}
  */
 public function getMimeEncoding(Pathname $pathname)
 {
     Validator::checkFile($pathname);
     $self = $this;
     return Util::executeFunction(function () use($pathname, $self) {
         return finfo_file(Util::getFileInfo(), $self->getBasePath() . $pathname->local(), FILEINFO_MIME_ENCODING);
     }, 'Filicious\\Exception\\AdapterException', 0, 'Could not get mime encoding of %s.', $pathname);
 }