This commit is contained in:
2026-04-15 19:34:56 +05:00
parent 34ffed1e4a
commit e243821f50
26 changed files with 2072 additions and 1258 deletions

View File

@@ -130,23 +130,9 @@ class Controller extends ExController
private function storeImageToS3($image): string
{
$path = '';
// first store temp file and resize it, then upload to s3
// 1 - store temp file
$tempPath = $image->store('temp', 'public');
if ($tempPath) {
$tempFilePath = storage_path('app/public/' . $tempPath);
$image = new ImageResize();
$path = $image->resize($tempPath, 322, 'brands');
// 2 - upload to s3 or keep local
if (in_array(env('FILESYSTEM_DISK'), ['s3', 'minio'])) {
Storage::disk('s3')->put($path, file_get_contents($path));
unlink($path);
}
}
return $path;
$resizer = new ImageResize();
return $resizer->resize($tempPath, 322, 'brands', true);
}
}

View File

@@ -101,31 +101,11 @@ class Store extends FormRequest
*/
public function getPosterThumb()
{
$url = $this->storeImageToS3($this->file('poster'));
return $url;
}
private function storeImageToS3($image): string
{
$path = '';
// first store temp file and resize it, then upload to s3
// 1 - store temp file
$image = $this->file('poster');
$tempPath = $image->store('temp', 'public');
if ($tempPath) {
// $tempFilePath = storage_path('app/public/' . $tempPath);
$image = new ImageResize();
$path = $image->resize($tempPath, 322, 'posters');
// 2 - upload to s3 or keep local
if (in_array(env('FILESYSTEM_DISK'), ['s3', 'minio'])) {
Storage::disk('s3')->put($path, file_get_contents($path));
unlink($path);
}
}
return $path;
$resizer = new ImageResize();
return $resizer->resize($tempPath, 322, 'posters', true);
}
/**

View File

@@ -123,40 +123,21 @@ class Update extends FormRequest
// delete old file from s3
Storage::disk('s3')->delete($product->poster_thumb);
} else {
// delete old file
unlink($product->poster_thumb);
// delete old file local
$oldPath = public_path($product->poster_thumb);
if (is_file($oldPath)) unlink($oldPath);
}
$url = $this->storeImageToS3($this->file('poster'));
return $url;
$image = $this->file('poster');
$tempPath = $image->store('temp', 'public');
$resizer = new ImageResize();
return $resizer->resize($tempPath, 322, 'posters', true);
}
return $product->poster_thumb;
}
private function storeImageToS3($image): string
{
$path = '';
// first store temp file and resize it, then upload to s3
// 1 - store temp file
$tempPath = $image->store('temp', 'public');
if ($tempPath) {
//$tempFilePath = storage_path('app/public/' . $tempPath);
$image = new ImageResize();
$path = $image->resize($tempPath, 322, 'posters');
// 2 - upload to s3 or keep local
if (in_array(env('FILESYSTEM_DISK'), ['s3', 'minio'])) {
Storage::disk('s3')->put($path, file_get_contents($path));
unlink($path);
}
}
return $path;
}
/**
* @return array
*/