You are here

protected function AvatarKitDownloadUtility::getExtension in Avatar Kit 8.2

Guess file extension for a response.

Parameters

\Psr\Http\Message\ResponseInterface $response: A response object.

Return value

string A file extension. 'file' is returned if no guess could be made.

1 call to AvatarKitDownloadUtility::getExtension()
AvatarKitDownloadUtility::createFile in src/AvatarKitDownloadUtility.php
Creates a file entity from a PSR response.

File

src/AvatarKitDownloadUtility.php, line 174

Class

AvatarKitDownloadUtility
Utility for creating Drupal files from responses.

Namespace

Drupal\avatars

Code

protected function getExtension(ResponseInterface $response) : string {
  $guesser = ExtensionGuesser::getInstance();
  $mime = $response
    ->getHeaderLine('Content-Type');
  return $guesser
    ->guess($mime) ?? 'file';
}