Ara's avatar
Level 3

Queuing a FileUpload

Hi guys,

So I am trying to queue a file upload by creating a job. Here is the code I have so far:

if($request->hasFile('photo')) {
                $path = "/img/members/{$member->slug}/";

                $photo_filename = str_replace(" ", "_", strtolower($request->file('photo')->getClientOriginalName()));
                $member->photo_path = $path . "" . $photo_filename;
                $image = $request->file('photo');

                $this->dispatch(new FileUploadJob($image, $photo_filename, $path));
            }

And here is the job file:

class FileUploadJob extends Job implements SelfHandling, ShouldQueue

...

public function handle()
        {
            Storage::disk('local')->put($this->path . "" . $this->filename, File::get($this->file));
        }

But I keep getting this error: Serialization of 'Symfony\Component\HttpFoundation\File\UploadedFile' is not allowed

Why is that?

Thanks, Ara

0 likes
0 replies

Please or to participate in this conversation.