This method am I using to destroy a users directory on Amazon S3
based on his/her Id
:
public function destroyDirectory(User $user)
{
if($this->directoryExists($user->id))
{
$job = (new DestroyDirectory($user))->onQueue('destroydirectory');
dispatch($job);
}
}
This is how my DestroyDirectory
job looks like:
public function __construct(User $user)
{
$this->user = $user;
}
public function handle()
{
Storage::disk('s3')->deleteDirectory('users/' . $this->user->id);
}
Locally this is working. But on my production server it only removes the file in the database (not in s3). I'm using more queues in my Laravel 5.3
application and they do work. So what could be going on here. I'm using Laravel Forge
. When I try this:
/**
* @param User $user
* @return bool
*/
public function destroyDirectory(User $user)
{
if($this->directoryExists($user->id))
{
Storage::disk('s3')->deleteDirectory('users/' . $this->user->id);
}
}
It's working!
In my failed_jobs
table I do not receive any errors. But I guess the job is being executed because it removes records from my database but not in s3
!