Skip to content

Commit

Permalink
Update MediaStorageService, improve support for pleroma .blob avatars
Browse files Browse the repository at this point in the history
  • Loading branch information
dansup committed Dec 13, 2022
1 parent aaed2bf commit 6622665
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions app/Services/MediaStorageService.php
Expand Up @@ -203,6 +203,7 @@ protected function fetchAvatar($avatar, $local = false)
}

$mimes = [
'application/octet-stream',
'image/jpeg',
'image/png',
];
Expand Down Expand Up @@ -239,6 +240,15 @@ protected function fetchAvatar($avatar, $local = false)
}
file_put_contents($tmpName, $data);

$mimeCheck = Storage::mimeType('remcache/' . $tmpPath);

if(!$mimeCheck || !in_array($mimeCheck, ['image/png', 'image/jpeg'])) {
$avatar->last_fetched_at = now();
$avatar->save();
unlink($tmpName);
return;
}

$disk = Storage::disk($driver);
$file = $disk->putFileAs($base, new File($tmpName), $path, 'public');
$permalink = $disk->url($file);
Expand Down

0 comments on commit 6622665

Please sign in to comment.