Skip to content

Commit 0c70ea1

Browse files
authored
Merge pull request #6670 from avalonmediasystem/always_inline_disposition
Override ActiveStorage to bypass forcing attachment disposition
2 parents fd9a260 + ab87cfa commit 0c70ea1

1 file changed

Lines changed: 17 additions & 0 deletions

File tree

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,19 @@
11
# This is set in config/application.rb but it seems like the settings aren't loaded at that point so doing it again here
22
Rails.application.config.active_storage.service = (Settings&.active_storage&.service.presence || "local").to_sym
3+
4+
Rails.application.config.to_prepare do
5+
# Override ActiveStorage behavior to allow inline disposition for all file types
6+
# See https://github.com/avalonmediasystem/avalon/issues/6399
7+
# and https://github.com/rails/rails/blob/v8.0.4/activestorage/app/models/active_storage/blob/servable.rb
8+
ActiveStorage::Blob::Servable.module_eval do
9+
def forcibly_serve_as_binary?
10+
#ActiveStorage.content_types_to_serve_as_binary.include?(content_type)
11+
false
12+
end
13+
14+
def allowed_inline?
15+
#ActiveStorage.content_types_allowed_inline.include?(content_type)
16+
true
17+
end
18+
end
19+
end

0 commit comments

Comments
 (0)