[Proposal] ActiveStorage should support an option to analyze_now when attaching a file

The primary motivation is to avoid enqueuing AnalyzeJob which downloads a file just to analyze it.

In a scenario where you save (attach) a file in a background job, you already have the file downloaded and you can analyze it right away as the code is executed in a background job. Having a separate job AnalyzeJob being enqueued and then performed to re-download the file just to analyze it seems not to be the optimal path in such case. Not only we download a file twice (including once from our storage which can incur some additional costs) but also we enqueue and perform an additional job. These actions can add up when dealing with a lot of files.

Curious what others think?

1 Like