* avatar content-type fixed

This commit is contained in:
Dávid Danyi 2018-08-06 18:03:21 +02:00
parent 18b0aab20c
commit 24438c93c5

View File

@ -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');
}