aboutsummaryrefslogtreecommitdiffstats
path: root/activestorage/app/models/active_storage/blob.rb
diff options
context:
space:
mode:
authorGeorge Claghorn <george.claghorn@gmail.com>2018-02-07 22:31:32 -0500
committerGitHub <noreply@github.com>2018-02-07 22:31:32 -0500
commitcc523fba9baf09849aeb59db28dab04135839f34 (patch)
treeb6b4d41c7a1e90dbb61218b5f2a4bb0fc180bc7a /activestorage/app/models/active_storage/blob.rb
parent5ae2ecab6d3365f6f17e3c8cb298dfeeea113774 (diff)
parent0625a2ba80476bf0139f2ecb9019dc2c82e4a7de (diff)
downloadrails-cc523fba9baf09849aeb59db28dab04135839f34.tar.gz
rails-cc523fba9baf09849aeb59db28dab04135839f34.tar.bz2
rails-cc523fba9baf09849aeb59db28dab04135839f34.zip
Merge pull request #31918 from huacnlee/fix/blob-service-url-for-string-filename
Fix `blob.service_url` for supports string type `:filename` option
Diffstat (limited to 'activestorage/app/models/active_storage/blob.rb')
-rw-r--r--activestorage/app/models/active_storage/blob.rb4
1 files changed, 3 insertions, 1 deletions
diff --git a/activestorage/app/models/active_storage/blob.rb b/activestorage/app/models/active_storage/blob.rb
index 892a833fae..a1e69e2264 100644
--- a/activestorage/app/models/active_storage/blob.rb
+++ b/activestorage/app/models/active_storage/blob.rb
@@ -109,7 +109,9 @@ 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, filename: self.filename, **options)
+ def service_url(expires_in: service.url_expires_in, disposition: :inline, filename: nil, **options)
+ filename = ActiveStorage::Filename.wrap(filename || self.filename)
+
service.url key, expires_in: expires_in, filename: filename, content_type: content_type,
disposition: forcibly_serve_as_binary? ? :attachment : disposition, **options
end