active_storage: document the virus scan hooks
This commit is contained in:
parent
52b7a82932
commit
d410e31344
2 changed files with 10 additions and 0 deletions
|
@ -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
|
||||||
|
|
||||||
|
|
|
@ -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 }
|
||||||
|
|
Loading…
Add table
Reference in a new issue