Skip to content

Commit

Permalink
wip (#46)
Browse files Browse the repository at this point in the history
  • Loading branch information
Jovert Lota Palonpon authored Apr 24, 2019
1 parent 60ea8bf commit b4ca8b8
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 7 deletions.
6 changes: 6 additions & 0 deletions .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,12 @@ MIX_PUSHER_APP_CLUSTER="${PUSHER_APP_CLUSTER}"

FILESYSTEM_DRIVER=public

AWS_ACCESS_KEY_ID=null
AWS_SECRET_ACCESS_KEY=null
AWS_DEFAULT_REGION=ap-northeast-1
AWS_BUCKET=laravel-react-admin
AWS_URL=https://laravel-react-admin.s3.ap-northeast-1.amazonaws.com

TELESCOPE_ENABLED=true

JWT_SECRET=noclue
Expand Down
28 changes: 21 additions & 7 deletions app/Utils/Uploader.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,14 +38,28 @@ public static function upload(string $directory, $file)
Storage::makeDirectory($thumbnailDirectory);
}

$fileSystemRoot = config("filesystems.disks.{$disk}.root");
$fullPath = "{$fileSystemRoot}/{$path}";
$fullThumbnailPath =
"{$fileSystemRoot}/{$thumbnailDirectory}/{$filename}";
switch ($disk) {
case 's3':
$fullThumbnailPath = "{$thumbnailDirectory}/{$filename}";

$image = Image::make($fullPath)
->fit(240)
->save($fullThumbnailPath, 95);
$image = Image::make($url)
->fit(240)
->stream();

Storage::put($fullThumbnailPath, $image->__toString());
break;

default:
$fileSystemRoot = config("filesystems.disks.{$disk}.root");
$fullPath = "{$fileSystemRoot}/{$path}";
$fullThumbnailPath =
"{$fileSystemRoot}/{$thumbnailDirectory}/{$filename}";

Image::make($fullPath)
->fit(240)
->save($fullThumbnailPath, 95);
break;
}

$thumbnail_filesize = Storage::size($thumbnailPath);
$thumbnail_url = Storage::url($thumbnailPath);
Expand Down

0 comments on commit b4ca8b8

Please sign in to comment.