From ce6ab80dba99f24b34b759e359e1af31379f15aa Mon Sep 17 00:00:00 2001 From: Daniel Supernault Date: Sun, 24 Jan 2021 21:07:28 -0700 Subject: [PATCH] Update MediaStorageService, clear transformer cache after storing media --- app/Services/MediaStorageService.php | 23 +++++++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-) diff --git a/app/Services/MediaStorageService.php b/app/Services/MediaStorageService.php index db7faf52c..025dfe977 100644 --- a/app/Services/MediaStorageService.php +++ b/app/Services/MediaStorageService.php @@ -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); - } } \ No newline at end of file