aboutsummaryrefslogtreecommitdiffstats
path: root/activestorage/lib
diff options
context:
space:
mode:
authorAndrew White <pixeltrix@users.noreply.github.com>2018-04-07 08:20:16 +0100
committerGitHub <noreply@github.com>2018-04-07 08:20:16 +0100
commitec7c89b5160015c014aad0c90f5679252a91cb37 (patch)
treed78e92d398270a1484027eda29100b5f8e33ae13 /activestorage/lib
parentcb2f69659e01a9ec4b09c70f2357b426ca9a1264 (diff)
parent9436c22e2aa9419f275186967a1b863bc3d01ecb (diff)
downloadrails-ec7c89b5160015c014aad0c90f5679252a91cb37.tar.gz
rails-ec7c89b5160015c014aad0c90f5679252a91cb37.tar.bz2
rails-ec7c89b5160015c014aad0c90f5679252a91cb37.zip
Merge pull request #32350 from rails/use-current-model-for-as-url-host
Use an ActiveSupport::CurrentAttributes model to provide the host for service urls
Diffstat (limited to 'activestorage/lib')
-rw-r--r--activestorage/lib/active_storage/service/disk_service.rb11
1 files changed, 7 insertions, 4 deletions
diff --git a/activestorage/lib/active_storage/service/disk_service.rb b/activestorage/lib/active_storage/service/disk_service.rb
index 75b66081c3..5b652fe74e 100644
--- a/activestorage/lib/active_storage/service/disk_service.rb
+++ b/activestorage/lib/active_storage/service/disk_service.rb
@@ -78,8 +78,9 @@ module ActiveStorage
verified_key_with_expiration = ActiveStorage.verifier.generate(key, expires_in: expires_in, purpose: :blob_key)
generated_url =
- url_helpers.rails_disk_service_path(
+ url_helpers.rails_disk_service_url(
verified_key_with_expiration,
+ host: current_host,
filename: filename,
disposition: content_disposition_with(type: disposition, filename: filename),
content_type: content_type
@@ -104,7 +105,7 @@ module ActiveStorage
purpose: :blob_token }
)
- generated_url = url_helpers.update_rails_disk_service_path(verified_token_with_expiration)
+ generated_url = url_helpers.update_rails_disk_service_url(verified_token_with_expiration, host: current_host)
payload[:url] = generated_url
@@ -129,7 +130,6 @@ module ActiveStorage
path_for(key).tap { |path| FileUtils.mkdir_p File.dirname(path) }
end
-
def ensure_integrity_of(key, checksum)
unless Digest::MD5.file(path_for(key)).base64digest == checksum
delete key
@@ -137,9 +137,12 @@ module ActiveStorage
end
end
-
def url_helpers
@url_helpers ||= Rails.application.routes.url_helpers
end
+
+ def current_host
+ ActiveStorage::Current.host
+ end
end
end