deepu07's avatar
Level 11

message: "Serialization of 'Illuminate\Http\UploadedFile' is not allowed"

Hello guys, In my project I'm trying to convert pdf to jpg and saving in aws (using spatie pdf to image package) so uploading pdf logic is in my controller after 10 mins delay I'm converting pdf to images by processing laravel job. here is my laravel-job logic

public function handle()
    {
        $filePath = 'images/' . $this->request->language . '/' . '_' . $this->request->language;
        $bookPath = $this->book->path;
        $destination_path = Storage::disk('s3')->url($filePath);
        
        $pdf = new Pdf($bookPath);
        $pdf->saveAllPagesAsImages($destination_path);
        return response()->json(['status' => 'True', 'msg' => 'Successfully converted']);
    }

somehow I'm getting Serialization of 'Illuminate\Http\UploadedFile' is not allowed" error. can anyone help me out? Thanks In advance.

0 likes
2 replies
tykus's avatar

You cannot pass the uploaded file to the Job, it should be written on disk/storage so that the job can retrieve it to process later. Your job can remove the unprocessed file after it has done the pdf-to-image conversion.

chatty's avatar

just move it to a temp folder and delete it afterwards

Please or to participate in this conversation.