Я попытался отправить мгновенный repsonse, не делая ничего в методе контроллера, даже это заняло слишком много времени 5 - 10 секунд < /p>
Это мой код < /p>
Код: Выделить всё
public function uploadImageAndGetPath($folder, $image)
{
$newFileName = $this->generateRandomString(20) . '.' . $image->getClientOriginalExtension();
$filePath = "uploads/$folder/$newFileName";
$imageContent = base64_encode($image->getContent());
// Dispatch job with the image content directly (no need to store it temporarily)
dispatch(new UploadImage($folder, $imageContent, $newFileName));
return $filePath;
}
public function handle()
{
$filePath = "uploads/{$this->folder}/{$this->fileName}";
$imageData = base64_decode($this->imagePath);
$img = Image::make($imageData);
$originalWidth = $img->width();
$originalHeight = $img->height();
$img->resize($originalWidth, $originalHeight, function ($constraint) {
$constraint->aspectRatio();
$constraint->upsize();
});
$compressedImage = (string) $img->encode('jpg', 75);
// Save the compressed image directly to S3
Storage::disk('s3')->put($filePath, $compressedImage, 'public');
}
Подробнее здесь: https://stackoverflow.com/questions/793 ... -much-time
Мобильная версия