models/attachment.rb
class Attachment < ApplicationRecord
after_initialize :set_storage
private
def set_storage
# larger that 5mb file would be upload on s3
if file.blob.byte_size > 5_000_000
Rails.application.config.active_storage.service = :amazon
else
Rails.application.config.active_storage.service = :local
end
end
# end of private
end
Comments
Post a Comment