You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

38 line
825B

  1. <?php
  2. namespace App\Jobs\File;
  3. use App\Codes\QueueName;
  4. use App\Files\TmpFile;
  5. use App\Jobs\BaseJob;
  6. use Illuminate\Support\Facades\Storage;
  7. class DeleteFile extends BaseJob
  8. {
  9. private string $fileId;
  10. private string $storagePath;
  11. /**
  12. * Create a new job instance.
  13. *
  14. * @return void
  15. */
  16. public function __construct(
  17. private TmpFile $file,
  18. ) {
  19. $this->onQueue(QueueName::JOB->value);
  20. $this->fileId = $file->getId();
  21. $this->storagePath = $file->getPath();
  22. logger("FILE削除JOB登録:" . $this->storagePath);
  23. }
  24. protected function handleJob()
  25. {
  26. if (Storage::exists($this->storagePath)) {
  27. Storage::delete($this->storagePath);
  28. info(sprintf("ファイル削除:%s ", $this->storagePath));
  29. }
  30. }
  31. }