You are here

protected static function Remote::mimeExtension in FileField Sources 8

Get/set the remote file extension in a static variable.

2 calls to Remote::mimeExtension()
Remote::parseHeader in src/Plugin/FilefieldSource/Remote.php
Parse cURL header and record the filename specified in Content-Disposition.
Remote::value in src/Plugin/FilefieldSource/Remote.php
Value callback for file field source plugin.

File

src/Plugin/FilefieldSource/Remote.php, line 262

Class

Remote
A FileField source plugin to allow downloading a file from a remote server.

Namespace

Drupal\filefield_sources\Plugin\FilefieldSource

Code

protected static function mimeExtension($curl_mime_type = NULL) {
  static $extension = NULL;
  $mimetype = mb_strtolower($curl_mime_type);
  $result = \Drupal::service('file.mime_type.guesser.extension')
    ->convertMimeTypeToMostCommonExtension($mimetype);
  if ($result) {
    $extension = $result;
  }
  return $extension;
}