2016-11-11 9 views
0

laravelのキュー(Bean)を使用してファイルをアップロードしようとしていますが、このエラーが発生します:'Illuminate \ Http \ UploadedFile'許可されていないLaravelキューエラー 'Illuminate Http UploadedFile'のシリアル化が許可されていません

私のコードです:

protected $file; 
    protected $Id; 

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

public function handle() 
    { 
     $qFile = $this->file; 
     $qId = $this->Id; 

     $s3 = Storage::disk('s3'); 
     $extension = $qFile->guessExtension(); 
     $filename = uniqid().'.'.$extension; 

     //Create and resize images 
     $image = Image::make($qFile)->resize(null, 600, function ($constraint) { 
      $constraint->aspectRatio(); 
     }); 
     $image->encode($extension); 

     $imageLarge = Image::make($qFile)->resize(null, 800, function ($constraint) { 
      $constraint->aspectRatio(); 
     }); 
     $imageLarge->encode($extension); 

     // upload image to S3 
     $s3->put("images/{$qId}/main/".$filename, (string) $image, 'public'); 
     $s3->put("images/{$qId}/large/".$filename, (string) $imageLarge, 'public'); 

     // make image entry to DB 
     File::create([ 
      'a_f_id' => $qId, 
      'file_name' => $filename, 
     ]); 
    } 

しかし、私は削除する場合:$ファイルを保護

。 protected $ Id;

私はエラーを受け取りません

+0

'protected $ file'を' private $ file'に変更しようとしましたか? –

答えて

0

アップロードされたファイルインスタンスをジョブに渡すことはできません。どこかにディスクに書き込んだ後、ジョブを処理するときにそれを取得する必要があります。

関連する問題