getMimeTypeByExtension() public méthode

Gets the mime type by just looking at the extension.
public getMimeTypeByExtension ( string $file ) : string
$file string the file to get the mimetype from
Résultat string the mimetype
 /**
  * {@inheritdoc}
  */
 public function renderFile(Entity $entity, $entityName, $field)
 {
     $fileName = $entity->get($field);
     $mimeTypes = new MimeTypes();
     $mimeType = $mimeTypes->getMimeTypeByExtension($fileName);
     $key = $this->getKey($entity, $entityName, $field) . '/' . $fileName;
     $result = $this->client->getObject(['Bucket' => $this->bucket, 'Key' => $key]);
     $result['Body']->rewind();
     $response = new StreamedResponse(function () use($result) {
         while ($data = $result['Body']->read(1024)) {
             echo $data;
             flush();
         }
     }, 200, ['Cache-Control' => 'public, max-age=86400', 'Content-length' => $result['ContentLength'], 'Content-Type' => $mimeType, 'Content-Disposition' => 'attachment; filename="' . $fileName . '"']);
     $response->send();
     return $response;
 }