Skip to content

Commit b4ca8b8

Browse files
author
Jovert Lota Palonpon
authored
wip (#46)
1 parent 60ea8bf commit b4ca8b8

File tree

2 files changed

+27
-7
lines changed

2 files changed

+27
-7
lines changed

.env.example

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,12 @@ MIX_PUSHER_APP_CLUSTER="${PUSHER_APP_CLUSTER}"
4444

4545
FILESYSTEM_DRIVER=public
4646

47+
AWS_ACCESS_KEY_ID=null
48+
AWS_SECRET_ACCESS_KEY=null
49+
AWS_DEFAULT_REGION=ap-northeast-1
50+
AWS_BUCKET=laravel-react-admin
51+
AWS_URL=https://laravel-react-admin.s3.ap-northeast-1.amazonaws.com
52+
4753
TELESCOPE_ENABLED=true
4854

4955
JWT_SECRET=noclue

app/Utils/Uploader.php

Lines changed: 21 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -38,14 +38,28 @@ public static function upload(string $directory, $file)
3838
Storage::makeDirectory($thumbnailDirectory);
3939
}
4040

41-
$fileSystemRoot = config("filesystems.disks.{$disk}.root");
42-
$fullPath = "{$fileSystemRoot}/{$path}";
43-
$fullThumbnailPath =
44-
"{$fileSystemRoot}/{$thumbnailDirectory}/{$filename}";
41+
switch ($disk) {
42+
case 's3':
43+
$fullThumbnailPath = "{$thumbnailDirectory}/{$filename}";
4544

46-
$image = Image::make($fullPath)
47-
->fit(240)
48-
->save($fullThumbnailPath, 95);
45+
$image = Image::make($url)
46+
->fit(240)
47+
->stream();
48+
49+
Storage::put($fullThumbnailPath, $image->__toString());
50+
break;
51+
52+
default:
53+
$fileSystemRoot = config("filesystems.disks.{$disk}.root");
54+
$fullPath = "{$fileSystemRoot}/{$path}";
55+
$fullThumbnailPath =
56+
"{$fileSystemRoot}/{$thumbnailDirectory}/{$filename}";
57+
58+
Image::make($fullPath)
59+
->fit(240)
60+
->save($fullThumbnailPath, 95);
61+
break;
62+
}
4963

5064
$thumbnail_filesize = Storage::size($thumbnailPath);
5165
$thumbnail_url = Storage::url($thumbnailPath);

0 commit comments

Comments
 (0)