aboutsummaryrefslogtreecommitdiffstats
path: root/activestorage/app
diff options
context:
space:
mode:
authorRosa Gutierrez <rosa.ge@gmail.com>2018-01-08 15:44:14 +0100
committerRosa Gutierrez <rosa.ge@gmail.com>2018-01-08 15:44:14 +0100
commit8f52d93576ec23c8e87c96f048585445f871efe5 (patch)
treee2fc3933684a49ddaf30ee007fc30ab97d15a58f /activestorage/app
parent7c69351277edaa47ee395c72d59623162eb8682f (diff)
downloadrails-8f52d93576ec23c8e87c96f048585445f871efe5.tar.gz
rails-8f52d93576ec23c8e87c96f048585445f871efe5.tar.bz2
rails-8f52d93576ec23c8e87c96f048585445f871efe5.zip
Allow overriding filename in `Blob#service_url`
This is useful when we have several representations for the same underlying file, each one with a different name, and we need to provide a custom download URL based on that name and not that of the underlying file.
Diffstat (limited to 'activestorage/app')
-rw-r--r--activestorage/app/models/active_storage/blob.rb2
1 files changed, 1 insertions, 1 deletions
diff --git a/activestorage/app/models/active_storage/blob.rb b/activestorage/app/models/active_storage/blob.rb
index 8fb53fa787..df4f6f6075 100644
--- a/activestorage/app/models/active_storage/blob.rb
+++ b/activestorage/app/models/active_storage/blob.rb
@@ -201,7 +201,7 @@ class ActiveStorage::Blob < ActiveRecord::Base
# with users. Instead, the +service_url+ should only be exposed as a redirect from a stable, possibly authenticated URL.
# Hiding the +service_url+ behind a redirect also gives you the power to change services without updating all URLs. And
# it allows permanent URLs that redirect to the +service_url+ to be cached in the view.
- def service_url(expires_in: service.url_expires_in, disposition: :inline)
+ def service_url(expires_in: service.url_expires_in, disposition: :inline, filename: self.filename)
service.url key, expires_in: expires_in, disposition: forcibly_serve_as_binary? ? :attachment : disposition, filename: filename, content_type: content_type
end