From f8cdd6e80d7eae45311bc7a45228857b9434f715 Mon Sep 17 00:00:00 2001 From: Dan Brown Date: Tue, 27 Apr 2021 20:36:42 +0100 Subject: [PATCH] Reduced calls for s3-based uploads Combined the public ACL update into the put operation. --- app/Uploads/ImageService.php | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/app/Uploads/ImageService.php b/app/Uploads/ImageService.php index 010b531f1..7793aaa01 100644 --- a/app/Uploads/ImageService.php +++ b/app/Uploads/ImageService.php @@ -106,8 +106,7 @@ class ImageService } try { - $storage->put($fullPath, $imageData); - $storage->setVisibility($fullPath, 'public'); + $storage->put($fullPath, $imageData, ['visibility' => 'public']); } catch (Exception $e) { \Log::error('Error when attempting image upload:' . $e->getMessage()); throw new ImageUploadException(trans('errors.path_not_writable', ['filePath' => $fullPath])); @@ -191,8 +190,7 @@ class ImageService $thumbData = $this->resizeImage($storage->get($imagePath), $width, $height, $keepRatio); - $storage->put($thumbFilePath, $thumbData); - $storage->setVisibility($thumbFilePath, 'public'); + $storage->put($thumbFilePath, $thumbData, ['visibility' => 'public']); $this->cache->put('images-' . $image->id . '-' . $thumbFilePath, $thumbFilePath, 60 * 60 * 72);