From 1199fb89f6d909ef9cdd027f050fe1a0816cfd78 Mon Sep 17 00:00:00 2001 From: Daniel Supernault Date: Tue, 24 Dec 2019 19:33:38 -0700 Subject: [PATCH 1/2] Update ImageUpdate pipeline job --- app/Jobs/ImageOptimizePipeline/ImageUpdate.php | 3 +++ 1 file changed, 3 insertions(+) diff --git a/app/Jobs/ImageOptimizePipeline/ImageUpdate.php b/app/Jobs/ImageOptimizePipeline/ImageUpdate.php index 8460a36d7..bcdf11c28 100644 --- a/app/Jobs/ImageOptimizePipeline/ImageUpdate.php +++ b/app/Jobs/ImageOptimizePipeline/ImageUpdate.php @@ -80,6 +80,9 @@ class ImageUpdate implements ShouldQueue $storagePath = "public/m/{$monthHash}/{$userHash}"; $file = Storage::disk(config('filesystems.cloud'))->putFile($storagePath, new File($path), 'public'); $url = Storage::disk(config('filesystems.cloud'))->url($file); + $thumbFile = Storage::disk(config('filesystems.cloud'))->putFile($storagePath, new File($thumb), 'public'); + $thumbUrl = Storage::disk(config('filesystems.cloud'))->url($thumbFile); + $media->thumbnail_url = $thumbUrl; $media->cdn_url = $url; $media->optimized_url = $url; $media->save(); From 6bb8099583c01d9fc834459f65a3784a3138d90d Mon Sep 17 00:00:00 2001 From: Daniel Supernault Date: Tue, 24 Dec 2019 19:34:16 -0700 Subject: [PATCH 2/2] Update VideoThumbnail pipeline job --- app/Jobs/VideoPipeline/VideoThumbnail.php | 25 +++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/app/Jobs/VideoPipeline/VideoThumbnail.php b/app/Jobs/VideoPipeline/VideoThumbnail.php index e988091f1..60e50e828 100644 --- a/app/Jobs/VideoPipeline/VideoThumbnail.php +++ b/app/Jobs/VideoPipeline/VideoThumbnail.php @@ -7,7 +7,10 @@ use Illuminate\Queue\SerializesModels; use Illuminate\Queue\InteractsWithQueue; use Illuminate\Contracts\Queue\ShouldQueue; use Illuminate\Foundation\Bus\Dispatchable; +use Illuminate\Http\File; +use Cache; use FFMpeg; +use Storage; use App\Media; class VideoThumbnail implements ShouldQueue @@ -58,5 +61,27 @@ class VideoThumbnail implements ShouldQueue } catch (Exception $e) { } + + if(config('pixelfed.cloud_storage') == true) { + $path = storage_path('app/'.$media->media_path); + $thumb = storage_path('app/'.$media->thumbnail_path); + $p = explode('/', $media->media_path); + $monthHash = $p[2]; + $userHash = $p[3]; + $storagePath = "public/m/{$monthHash}/{$userHash}"; + $file = Storage::disk(config('filesystems.cloud'))->putFile($storagePath, new File($path), 'public'); + $url = Storage::disk(config('filesystems.cloud'))->url($file); + $thumbFile = Storage::disk(config('filesystems.cloud'))->putFile($storagePath, new File($thumb), 'public'); + $thumbUrl = Storage::disk(config('filesystems.cloud'))->url($thumbFile); + $media->thumbnail_url = $thumbUrl; + $media->cdn_url = $url; + $media->optimized_url = $url; + $media->save(); + + } + + if($media->status_id) { + Cache::forget('status:transformer:media:attachments:' . $media->status_id); + } } }