test
This commit is contained in:
@@ -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
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user