]> BookStack Code Mirror - bookstack/commitdiff
Reduced calls for s3-based uploads
authorDan Brown <redacted>
Tue, 27 Apr 2021 19:36:42 +0000 (20:36 +0100)
committerDan Brown <redacted>
Tue, 27 Apr 2021 19:36:42 +0000 (20:36 +0100)
Combined the public ACL update into the put operation.

app/Uploads/ImageService.php

index 010b531f1042d1714205474fc5437a9e6078f0be..7793aaa01ee7363f01d9b9b62215dbc65092ba4d 100644 (file)
@@ -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);