diff --git a/src/App/Action/AvatarAction.php b/src/App/Action/AvatarAction.php index 7e0b65a..184d26d 100644 --- a/src/App/Action/AvatarAction.php +++ b/src/App/Action/AvatarAction.php @@ -3,6 +3,7 @@ namespace App\Action; use App\Service\AvatarService; +use finfo; use Interop\Http\ServerMiddleware\DelegateInterface; use Interop\Http\ServerMiddleware\MiddlewareInterface as ServerMiddlewareInterface; use Psr\Http\Message\ServerRequestInterface; @@ -31,8 +32,10 @@ class AvatarAction implements ServerMiddlewareInterface } catch (\UnexpectedValueException $e) { return new TextResponse("Avatar not found", 404); } + $finfo = new finfo(FILEINFO_MIME_TYPE); + $contentType = $finfo->buffer($avatarImageData); return (new TextResponse($avatarImageData, 200, [ - 'content-type' => 'image/png', + 'content-type' => $contentType, ]))->withHeader('Expires', '0') ->withHeader('Cache-Control', 'must-revalidate'); }