Update MediaStorageService, clear transformer cache after storing media

This commit is contained in:
Daniel Supernault 2021-01-24 21:07:28 -07:00
parent f930c4bda2
commit ce6ab80dba
No known key found for this signature in database
GPG Key ID: 0DEF1C662C9033F7
1 changed files with 21 additions and 2 deletions

View File

@ -99,7 +99,23 @@ class MediaStorageService {
return;
}
$ext = $mime == 'image/jpeg' ? '.jpg' : ($mime == 'image/png' ? '.png' : 'mp4');
switch ($mime) {
case 'image/png':
$ext = '.png';
break;
case 'image/gif':
$ext = '.gif';
break;
case 'image/jpeg':
$ext = '.jpg';
break;
case 'video/mp4':
$ext = '.mp4';
break;
}
$base = MediaPathService::get($media->profile);
$path = Str::random(40) . $ext;
@ -118,7 +134,10 @@ class MediaStorageService {
$media->replicated_at = now();
$media->save();
if($media->status_id) {
Cache::forget('status:transformer:media:attachments:' . $media->status_id);
}
unlink($tmpName);
}
}