aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGeorge Claghorn <george@basecamp.com>2018-04-25 12:47:54 -0500
committerGeorge Claghorn <george@basecamp.com>2018-04-25 12:47:58 -0500
commit052fcef0cb405a3fa3a46349a9d979c2e0d4c160 (patch)
tree66cd43b0b9685cf56f73ee4679bcb89b5b2fe837
parent13ec9fed04954cc9a435b568c50bfe0c3e8836ee (diff)
downloadrails-052fcef0cb405a3fa3a46349a9d979c2e0d4c160.tar.gz
rails-052fcef0cb405a3fa3a46349a9d979c2e0d4c160.tar.bz2
rails-052fcef0cb405a3fa3a46349a9d979c2e0d4c160.zip
Simplify URL generation for partial downloads from GCS
-rw-r--r--activestorage/lib/active_storage/service/gcs_service.rb3
1 files changed, 2 insertions, 1 deletions
diff --git a/activestorage/lib/active_storage/service/gcs_service.rb b/activestorage/lib/active_storage/service/gcs_service.rb
index 369c33cbdb..16a0765fc5 100644
--- a/activestorage/lib/active_storage/service/gcs_service.rb
+++ b/activestorage/lib/active_storage/service/gcs_service.rb
@@ -48,7 +48,8 @@ module ActiveStorage
def download_chunk(key, range)
instrument :download_chunk, key: key, range: range do
- uri = URI(url(key, expires_in: 30.seconds, filename: ActiveStorage::Filename.new(""), content_type: "application/octet-stream", disposition: "inline"))
+ file = file_for(key)
+ uri = URI(file.signed_url(expires: 30.seconds))
Net::HTTP.start(uri.host, uri.port, use_ssl: uri.scheme == "https") do |client|
client.get(uri, "Range" => "bytes=#{range.begin}-#{range.exclude_end? ? range.end - 1 : range.end}").body