dimanche 28 février 2016

How upload big files to S3 in laravel 5 with Queue?

How can I upload big files using Queue to AWS S3 in Laravel 5 ?

I want use queue but I don't get it how is possible pass the file to the Queue handle method ? my code:

////////////My controller

public function uploadToS3Queque(Request $request)
{
if ($request->hasFile('file')) {

    $job = (new UploadToS3($request->file('file')))->delay(10);
  $this->dispatch($job); 

}

}

////////////////my job

class UploadToS3 extends Job implements SelfHandling, ShouldQueue
{
use InteractsWithQueue, SerializesModels;
protected $file;

public function __construct($file)
{
    $this->file = file;
}

public function handle()
{

    Storage::disk('s3')->getDriver()->put('bucket/image.jpg',$this->file); 
}
}

with that code I get this error message:

Exception in Queue.php line 92:
Serialization of 'Symfony\Component\HttpFoundation\File\UploadedFile' is not allowed

How should I pass the file to the queue?

Thanks



from Newest questions tagged laravel-5 - Stack Overflow http://ift.tt/1oI8LiG
via IFTTT

Aucun commentaire:

Enregistrer un commentaire