active_storage: document the virus scan hooks

This commit is contained in:
Pierre de La Morinerie 2019-05-28 11:35:42 +02:00
parent 52b7a82932
commit d410e31344
2 changed files with 10 additions and 0 deletions

View file

@ -1,3 +1,7 @@
# TODO: once we're using Rails 6, use the hooks on attachments creation
# (rather than on blob creation).
# This will help to avoid cloberring metadata accidentally (as metadata
# are more stable on attachment creation than on blob creation).
module BlobVirusScanner module BlobVirusScanner
extend ActiveSupport::Concern extend ActiveSupport::Concern

View file

@ -1,3 +1,9 @@
ActiveStorage::Service.url_expires_in = 1.hour ActiveStorage::Service.url_expires_in = 1.hour
# In Rails 5.2, we have to hook at `on_load` on the blob themeselves, which is
# not ideal.
#
# Rails 6 adds support for `.on_load(:active_storage_attachment)`, which is
# cleaner (as it allows to enqueue the virus scan on attachment creation, rather
# than on blob creation).
ActiveSupport.on_load(:active_storage_blob) { include BlobVirusScanner } ActiveSupport.on_load(:active_storage_blob) { include BlobVirusScanner }