1
0
Fork 0
mirror of https://github.com/rails/rails.git synced 2022-11-09 12:12:34 -05:00

Merge pull request #30135 from ffmike/azure-storage-fix-content-type

Support content_type in AzureStorageService#url
This commit is contained in:
Rafael Mendonça França 2017-08-08 14:41:44 -04:00
commit 1422e9f9c9
2 changed files with 11 additions and 3 deletions

View file

@ -57,11 +57,12 @@ module ActiveStorage
end end
end end
def url(key, expires_in:, disposition:, filename:) def url(key, expires_in:, disposition:, filename:, content_type:)
instrument :url, key do |payload| instrument :url, key do |payload|
base_url = url_for(key) base_url = url_for(key)
generated_url = signer.signed_uri(URI(base_url), false, permissions: "r", generated_url = signer.signed_uri(URI(base_url), false, permissions: "r",
expiry: format_expiry(expires_in), content_disposition: "#{disposition}; filename=\"#{filename}\"").to_s expiry: format_expiry(expires_in), content_type: content_type,
content_disposition: "#{disposition}; filename=\"#{filename}\"").to_s
payload[:url] = generated_url payload[:url] = generated_url

View file

@ -6,8 +6,15 @@ if SERVICE_CONFIGURATIONS[:azure]
SERVICE = ActiveStorage::Service.configure(:azure, SERVICE_CONFIGURATIONS) SERVICE = ActiveStorage::Service.configure(:azure, SERVICE_CONFIGURATIONS)
include ActiveStorage::Service::SharedServiceTests include ActiveStorage::Service::SharedServiceTests
end
test "signed URL generation" do
url = @service.url(FIXTURE_KEY, expires_in: 5.minutes,
disposition: :inline, filename: "avatar.png", content_type: "image/png")
assert_match(/(\S+)&rsct=image%2Fpng&rscd=inline%3B\+filename%3D%22avatar.png/, url)
assert_match SERVICE_CONFIGURATIONS[:azure][:container], url
end
end
else else
puts "Skipping Azure Storage Service tests because no Azure configuration was supplied" puts "Skipping Azure Storage Service tests because no Azure configuration was supplied"
end end