file = $file; } /** * Execute the job. */ public function handle(): void { // get file from constructor $file = $this->file; // if the file has not been uploaded to S3 if (!$file->s3) { $localPath = Storage::disk('local')->path($file->stored_at); Log::debug("File at " . $localPath . " being uploaded to S3"); // upload file to S3 try { // upload to S3 with the "stored_at" path. get file from 'local' disk at the "stored_at" path. $stored = Storage::put($file->stored_at, Storage::disk('local')->get($file->stored_at)); // if storing is successful, change DB and output log message if ($stored) { Log::debug("File uploaded to S3"); $file->s3 = 1; $file->saveQuietly(); } // else file storing on S3 was not successful. else { Log::error("File upload to S3 was unsuccessful"); } } catch (\Exception $exception) { Log::error($exception->getMessage()); } } // else do nothing } }