@@ -83,15 +83,16 @@ def self.extended base
8383
8484 def expiring_url ( time = 3600 , style_name = default_style )
8585 if path ( style_name )
86- uri = URI azure_uri ( style_name )
86+ uri = URI " #{ container_name } / #{ path ( style_name ) . gsub ( %r{ \A /} , '' ) } "
8787 generator = ::Azure ::Storage ::Core ::Auth ::SharedAccessSignature . new azure_account_name ,
88- azure_credentials [ : storage_access_key]
88+ azure_storage_client . storage_access_key
8989
9090 generator . signed_uri uri , false , service : 'b' ,
9191 resource : 'b' ,
9292 permissions : 'r' ,
9393 start : ( Time . now - ( 5 * 60 ) ) . utc . iso8601 ,
9494 expiry : ( Time . now + time ) . utc . iso8601
95+ azure_interface . generate_uri uri . path , CGI ::parse ( uri . query || "" )
9596 else
9697 url ( style_name )
9798 end
@@ -107,10 +108,7 @@ def azure_credentials
107108 end
108109
109110 def azure_account_name
110- account_name = @options [ :azure_storage_account_name ] || azure_credentials [ :storage_account_name ]
111- account_name = account_name . call ( self ) if account_name . is_a? ( Proc )
112-
113- account_name
111+ azure_storage_client . storage_account_name
114112 end
115113
116114 def container_name
@@ -132,15 +130,17 @@ def azure_interface
132130 end
133131
134132 def azure_storage_client
135- config = { }
133+ @azure_storage_client ||= begin
134+ config = { }
136135
137- [ :storage_account_name , :storage_access_key ] . each do |opt |
138- config [ opt ] = azure_credentials [ opt ] if azure_credentials [ opt ]
139- end
136+ [ :storage_account_name , :storage_access_key , :use_development_storage ] . each do |opt |
137+ config [ opt ] = azure_credentials [ opt ] if azure_credentials [ opt ]
138+ end
140139
141- config [ :storage_blob_host ] = "https://#{ azure_base_url } "
140+ config [ :storage_blob_host ] = "https://#{ Environment . url_for azure_account_name , azure_credentials [ :region ] } " if azure_credentials [ :region ]
142141
143- @azure_storage_client ||= ::Azure ::Storage ::Client . create config
142+ ::Azure ::Storage ::Client . create config
143+ end
144144 end
145145
146146 def obtain_azure_instance_for ( options )
@@ -154,7 +154,7 @@ def obtain_azure_instance_for(options)
154154 end
155155
156156 def azure_uri ( style_name = default_style )
157- "https:// #{ azure_base_url } /#{ container_name } /#{ path ( style_name ) . gsub ( %r{\A /} , '' ) } "
157+ "#{ azure_storage_client . storage_blob_host } /#{ container_name } /#{ path ( style_name ) . gsub ( %r{\A /} , '' ) } "
158158 end
159159
160160 def azure_base_url
0 commit comments