galaners's avatar

Upload files during a queue listener (job)

I'm using Redis in my application through the phpredis extension. Everything works flawless, but one of my methods requires uploading multiple images to the server (process that I want to perform asynchronously through queues). But the problem here is that, apparently, you can't upload files through Redis jobs (casting event/listeners). So I'm wondering if one of the other drivers (database or the amazon one, I believe is S3 or something like that) could do the job, or if there's a way to upload files trough Redis

0 likes
3 replies
tykus's avatar

Store the uploaded file to a temporary directory, and pass the temporary path to the Job 🤷‍♂️

Snapey's avatar

you have to deal with the uploaded file during the request cycle

as suggested you could just accept the file in the request and then process it later

martinbean's avatar

one of my methods requires uploading multiple images to the server (process that I want to perform asynchronously through queues). But the problem here is that, apparently, you can't upload files through Redis jobs (casting event/listeners)

@galaners You can’t do this with any queue driver. A queue job is handled asynchronously only when a worker has capacity. That might be immediately, but it may also be in a few seconds, or a few minutes, depending on how many jobs are in your queue already.

Where are uploaded files supposed to live in the time between a user submitting a request to your service, and your worker process picking up a job? Uploaded files don’t just magically hang around in the ether waiting for you to process them, they still need to be uploaded to your server.

Please or to participate in this conversation.