DEV Community

Discussion on: Prevent ActiveStorage to kill your Rails app

Collapse
alecrust profile image
Alec Rust

Nice!

Passing file directly to ResizePhotoJob doesn't work for me as jobs don't seem to be able to accept ActiveStorage::Attached::One as a param. file.attachment works though (passing a ActiveStorage::Attachment instead).

Do you know if calling processed on the variant will also queue up an AnalyzeJob for the variant blob? Or should we also call variant.blob.analyze in ResizePhotoJob?

As well as the variant being created in a background job before the user requests it, I want that variant to be analyzed too so that the dimensions metadata is available before first request.

Collapse
zimski profile image
CHADDA Chakib Author

Hey !
I think the AnalyzeJob is called when the upload is done. I should dive on the rails code to be sure.

Meanwhile, The meta data is needed to know if it’s an image, pdf or a regular file.
This data is also needed to choose the right processor to compress or resize.
So this should be done as soon as possible ( technically just after the upload is done )

Collapse
alecrust profile image
Alec Rust

I believe AnalyzeJob for the variant does get queued when processed is called, not sure how quickly it occurs though. Maybe calling analyze after processed in the job would be wise.