diff options
author | George Claghorn <george@basecamp.com> | 2018-04-25 12:47:54 -0500 |
---|---|---|
committer | George Claghorn <george@basecamp.com> | 2018-04-25 12:47:58 -0500 |
commit | 052fcef0cb405a3fa3a46349a9d979c2e0d4c160 (patch) | |
tree | 66cd43b0b9685cf56f73ee4679bcb89b5b2fe837 | |
parent | 13ec9fed04954cc9a435b568c50bfe0c3e8836ee (diff) | |
download | rails-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.rb | 3 |
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 |