Fix errors in AvatarController when data() returns null

Signed-off-by: Côme Chilliet <come.chilliet@nextcloud.com>
This commit is contained in:
Côme Chilliet 2021-10-25 16:17:27 +02:00
parent 8b271b8a12
commit 5a20e20e9e
No known key found for this signature in database
GPG key ID: A3E2F658B28C760A

View file

@ -283,11 +283,12 @@ class AvatarController extends Controller {
$image = new \OC_Image();
$image->loadFromData($tmpAvatar);
$resp = new DataDisplayResponse($image->data(),
$resp = new DataDisplayResponse(
$image->data() ?? '',
Http::STATUS_OK,
['Content-Type' => $image->mimeType()]);
$resp->setETag((string)crc32($image->data()));
$resp->setETag((string)crc32($image->data() ?? ''));
$resp->cacheFor(0);
$resp->setLastModified(new \DateTime('now', new \DateTimeZone('GMT')));
return $resp;