Image source not readable (Upload Job Exception)

Posted 8 months ago by splendidkeen

I am trying to handle uploads this way:

First upload the requested file locally, then trigger a UploadLogo Job to push the file to S3 and delete the local pathed-file.

I am always getting this exception:

Intervention\Image\Exception\NotReadableException: Image source not readable 
...

This is my setup:

UploadLogo.php (Job)

public $partner;
public $filename;
    

public function __construct($partner, $filename)
{
        $this->partner = $partner;
        $this->filename = $filename;
}

public function handle()
{
        $path = public_path() . '/uploads/partners/logos/' . $this->filename;
        $filename = $this->filename;

        if (Storage::disk('s3')->put('/uploads/partners/logos/'. $filename, fopen($path, 'r+'))) {
            File::delete($path);
        }
 
        $partner->logo_filename = $filename;
        $partner->save();
}

UploadController.php

public function uploadLogo(Request $request, Partner $partner){

//Validation...

if($request->hasFile('logo')){
    if ($request->file('logo')->isValid()) {
        $partner = Auth::user();

        $image = $request->file('logo');

        $filename = time() . '.' . $image->getClientOriginalExtension();
        $location = public_path('uploads/partners/logos/'. $filename);
        Image::make($image)->resize(300,300)->save($location);

        $partner->logo_filename = $filename;
        $partner->save();
                           
        $this->dispatch(new UploadLogo($partner, $filename));
    }

//Redirect with Info

}
}

Please sign in or create an account to participate in this conversation.

Laracasts Mascot

Hi, Have We Met Yet?

Did you know that, in addition to the forum, Laracasts includes well over 1000 lessons on modern web development? All for the price of one lunch out per month.

Sign Me Up

Channels

Reply to

Use Markdown with GitHub-flavored code blocks.