I
I
Iossarian2021-01-11 15:47:03
Yii
Iossarian, 2021-01-11 15:47:03

What is the problem of downloading a file in a queue?

Good afternoon. I came across a problem with the inability to upload a file to the server in the queue. I use yiisoft/yii2-queue with redis driver.

$this->video = hash('MD5', $this->video_file->baseName . floor($this->task_id / 1000)) . '.' . $this->video_file->extension;
$filepath = $this->getRelativeVideoPath() . $this->video;
Yii::$app->queue->push(new TaskVideoJob([
            'file' => $this->video_file,
            'path' => $filepath,
]));


class TaskVideoJob extends BaseObject implements JobInterface
{
    public $file;
    public $path;

    public function execute($queue)
    {
        $this->file->saveAs($this->path);
    }
}

The path definitely exists. It is created by the getRelativeVideoPath() method. If you save right there at the place where the queue was called, then the file is saved without problems. Similarly, any other actions in the queue work. Saving the file doesn't work. Queue/info marks the job as completed.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
V
vilinyh, 2021-01-11
@vilinyh

95% that UploadedFile was "incorrectly" serialized when pushing to the queue, and another 5% that the worker is generally on a different server.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question