diff options
author | Andrew White <andrew.white@unboxed.co> | 2018-03-12 17:34:42 +0000 |
---|---|---|
committer | Andrew White <andrew.white@unboxed.co> | 2018-03-12 17:39:58 +0000 |
commit | 309bb6c4d068b0d480681cf4ef1b90158527dfe5 (patch) | |
tree | bc3544c31121bf60388e5fbe7a59ed28907aed88 | |
parent | 7bede102d2fb279204665cb5c80249eace486021 (diff) | |
download | rails-309bb6c4d068b0d480681cf4ef1b90158527dfe5.tar.gz rails-309bb6c4d068b0d480681cf4ef1b90158527dfe5.tar.bz2 rails-309bb6c4d068b0d480681cf4ef1b90158527dfe5.zip |
Remove path config option from Azure service
The Active Storage service for Azure Storage has an option called `path`
that is ambiguous in meaning. It needs to be set to the primary blob
storage endpoint but that can be determined from the blobs client anyway.
To simplify the configuration this commit removes the `path` option and
gets the endpoint from the blobs client instead.
Closes #32225.
-rw-r--r-- | activestorage/lib/active_storage/service/azure_storage_service.rb | 16 | ||||
-rw-r--r-- | activestorage/test/service/configurations.example.yml | 1 | ||||
-rw-r--r-- | guides/source/active_storage_overview.md | 1 |
3 files changed, 10 insertions, 8 deletions
diff --git a/activestorage/lib/active_storage/service/azure_storage_service.rb b/activestorage/lib/active_storage/service/azure_storage_service.rb index 5682087469..ff6b2be135 100644 --- a/activestorage/lib/active_storage/service/azure_storage_service.rb +++ b/activestorage/lib/active_storage/service/azure_storage_service.rb @@ -8,14 +8,13 @@ module ActiveStorage # Wraps the Microsoft Azure Storage Blob Service as an Active Storage service. # See ActiveStorage::Service for the generic API documentation that applies to all services. class Service::AzureStorageService < Service - attr_reader :client, :path, :blobs, :container, :signer + attr_reader :client, :blobs, :container, :signer - def initialize(path:, storage_account_name:, storage_access_key:, container:) + def initialize(storage_account_name:, storage_access_key:, container:) @client = Azure::Storage::Client.create(storage_account_name: storage_account_name, storage_access_key: storage_access_key) @signer = Azure::Storage::Core::Auth::SharedAccessSignature.new(storage_account_name, storage_access_key) @blobs = client.blob_client @container = container - @path = path end def upload(key, io, checksum: nil) @@ -87,6 +86,7 @@ module ActiveStorage base_url = url_for(key) generated_url = signer.signed_uri( URI(base_url), false, + service: "b", permissions: "r", expiry: format_expiry(expires_in), content_disposition: content_disposition_with(type: disposition, filename: filename), @@ -102,8 +102,12 @@ module ActiveStorage def url_for_direct_upload(key, expires_in:, content_type:, content_length:, checksum:) instrument :url, key: key do |payload| base_url = url_for(key) - generated_url = signer.signed_uri(URI(base_url), false, permissions: "rw", - expiry: format_expiry(expires_in)).to_s + generated_url = signer.signed_uri( + URI(base_url), false, + service: "b", + permissions: "rw", + expiry: format_expiry(expires_in) + ).to_s payload[:url] = generated_url @@ -117,7 +121,7 @@ module ActiveStorage private def url_for(key) - "#{path}/#{container}/#{key}" + "#{blobs.host}/#{container}/#{key}" end def blob_for(key) diff --git a/activestorage/test/service/configurations.example.yml b/activestorage/test/service/configurations.example.yml index 43cc013bc8..a63aa33302 100644 --- a/activestorage/test/service/configurations.example.yml +++ b/activestorage/test/service/configurations.example.yml @@ -24,7 +24,6 @@ # # azure: # service: AzureStorage -# path: "" # storage_account_name: "" # storage_access_key: "" # container: "" diff --git a/guides/source/active_storage_overview.md b/guides/source/active_storage_overview.md index 014fd57052..831a02a9a1 100644 --- a/guides/source/active_storage_overview.md +++ b/guides/source/active_storage_overview.md @@ -121,7 +121,6 @@ Declare an Azure Storage service in `config/storage.yml`: ```yaml azure: service: AzureStorage - path: "" storage_account_name: "" storage_access_key: "" container: "" |