wottavm's avatar

[question] Realtime folder checking

Hello everyone,

I want to know if I can do the following thing and how to set it up in a good way.

The idea : I need to check realtime if files have been uploaded to a upload folder ( outside of laravel most likely ). Then when a certain amount of files have been uploaded ( let's say 20 ) I need to do something with those files. In this case that can be creating one pdf file per 20.

When the pdf has been made it should be placed in an order folder. This process can be done while generating pdf's.

So now is my question : Can I create a job and a queue that can do this for me. Most likely this should always be running.

I might even built in some check so if the code would stop working and I restart it, it would still pick the oldest uploaded file first.

Can somebody tell me if this is possible and how I can achieve this.

Best regards, Wouter.

0 likes
1 reply
luceos's avatar

Hello Wouter,

If you are not the party handling the uploads I would most likely create a cron that polls for new files and triggers an event. Through an event listener you can then listen on these events, update a persisted count (database or redis or something) and on every N, you trigger a queue job to start processing the batch of files. If you are unaware about the filenames I'd suggest adding the filename to the event and persisting them to the database. After they have been processed you can then set a processed_at date flag.

Hope this helps!

Please or to participate in this conversation.