Created
September 18, 2022 17:18
-
-
Save arif98741/0a2957b88631bff6f9e5f2893cb114eb to your computer and use it in GitHub Desktop.
Store Image using S3
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
if (config('app.env') == 'production') { | |
$width = $thumbnail_values[1]->value; | |
$height = $thumbnail_values[0]->value; | |
$destinationPath = 'images/media/' . $directory . '/'; | |
$thumbnailImage = Image::make($request->file('file'))->resize($width, $height)->stream(); | |
$namethumbnail = $destinationPath . 'thumbnail' . time() . $filename; | |
Storage::disk('s3')->put($destinationPath . 'thumbnail' . time() . $filename, $thumbnailImage->__toString()); | |
$Path = 'images/media/' . $directory . '/' . 'thumbnail' . time() . $filename; | |
} else { | |
$destinationPath = public_path('images/media/' . $directory . '/'); | |
$thumbnailImage = Image::make($request->file('file'), array( | |
'width' => $thumbnail_values[1]->value, | |
'height' => $thumbnail_values[0]->value, | |
'grayscale' => false) | |
); | |
$namethumbnail = $thumbnailImage->save($destinationPath . 'thumbnail' . time() . $filename); | |
$Path = 'images/media/' . $directory . '/' . 'thumbnail' . time() . $filename; | |
$destinationFile = public_path($Path); | |
$size = getimagesize($destinationFile); | |
list($width, $height, $type, $attr) = $size; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment