-
Notifications
You must be signed in to change notification settings - Fork 346
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
support Azure Blob storage #363
Conversation
it depends on fog-azure-rm gem
because, it was crashed in Azure::Storage::Core::Utility#parse_charset_from_content_type that expected a String object
Thanks for the PR |
lib/asset_sync/config.rb
Outdated
else | ||
raise ArgumentError, "AssetSync Unknown provider: #{fog_provider} only AWS, Rackspace and Google are supported currently." | ||
end | ||
|
||
options.merge!({:region => fog_region}) if fog_region && !rackspace? | ||
options.merge!({:region => fog_region}) if fog_region && !rackspace? && !azure_rm? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should really put this line into every if
except rackspace
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I can refactor this later you can leave this unchanged :P
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do you mean like below?
if aws?
...
options.merge!({:region => fog_region}) if fog_region
elsif rackspace?
...
options.merge!({:rackspace_region => fog_region}) if fog_region
elsif google?
...
options.merge!({:region => fog_region}) if fog_region
elsif azure_rm?
...
options.merge!({:environment => fog_region}) if fog_region
else
...
end
lib/asset_sync/storage.rb
Outdated
@@ -202,6 +202,10 @@ def upload_file(f) | |||
}) | |||
end | |||
|
|||
if config.azure_rm? | |||
file[:content_type] = file[:content_type].content_type if file[:content_type].is_a?(::MIME::Type) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Don't quite understand why this is needed
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure, sorry...
but, I got an error as below without the content_type conversion.
rake aborted!
NoMethodError: undefined method `length' for #<MIME::Type:0x007fda42e79040>
vendor/bundle/ruby/2.3.0/gems/azure-storage-0.11.5.preview/lib/azure/storage/core/utility.rb:112:in `parse_charset_from_content_type'
vendor/bundle/ruby/2.3.0/gems/azure-storage-0.11.5.preview/lib/azure/storage/blob/blob_service.rb:54:in `call'
vendor/bundle/ruby/2.3.0/gems/azure-storage-0.11.5.preview/lib/azure/storage/blob/block.rb:114:in `create_block_blob'
vendor/bundle/ruby/2.3.0/gems/fog-azure-rm-0.3.8/lib/fog/azurerm/requests/storage/create_block_blob.rb:31:in `create_block_blob'
vendor/bundle/ruby/2.3.0/gems/fog-azure-rm-0.3.8/lib/fog/azurerm/models/storage/file.rb:250:in `save_blob'
vendor/bundle/ruby/2.3.0/gems/fog-azure-rm-0.3.8/lib/fog/azurerm/models/storage/file.rb:93:in `save'
vendor/bundle/ruby/2.3.0/gems/fog-core-1.45.0/lib/fog/core/collection.rb:50:in `create'
vendor/bundle/ruby/2.3.0/bundler/gems/asset_sync-2fa4d474d97e/lib/asset_sync/storage.rb:205:in `upload_file'
vendor/bundle/ruby/2.3.0/bundler/gems/asset_sync-2fa4d474d97e/lib/asset_sync/storage.rb:220:in `block in upload_files'
vendor/bundle/ruby/2.3.0/bundler/gems/asset_sync-2fa4d474d97e/lib/asset_sync/storage.rb:218:in `each'
vendor/bundle/ruby/2.3.0/bundler/gems/asset_sync-2fa4d474d97e/lib/asset_sync/storage.rb:218:in `upload_files'
vendor/bundle/ruby/2.3.0/bundler/gems/asset_sync-2fa4d474d97e/lib/asset_sync/storage.rb:234:in `sync'
vendor/bundle/ruby/2.3.0/bundler/gems/asset_sync-2fa4d474d97e/lib/asset_sync/asset_sync.rb:29:in `block in sync'
vendor/bundle/ruby/2.3.0/bundler/gems/asset_sync-2fa4d474d97e/lib/asset_sync/asset_sync.rb:51:in `with_config'
vendor/bundle/ruby/2.3.0/bundler/gems/asset_sync-2fa4d474d97e/lib/asset_sync/asset_sync.rb:28:in `sync'
vendor/bundle/ruby/2.3.0/bundler/gems/asset_sync-2fa4d474d97e/lib/tasks/asset_sync.rake:5:in `block (2 levels) in <top (required)>'
vendor/bundle/ruby/2.3.0/bundler/gems/asset_sync-2fa4d474d97e/lib/tasks/asset_sync.rake:28:in `block in <top (required)>'
I think Azure::Storage::Core::Utility#parse_charset_from_content_type
needs content_type
as a String, not as a MIME::Type, because it calls length
and split(';')
methods of content_type
. so, I put the code to convert from MIME::Type to String.
module Azure::Storage
module Core
module Utility
...
def parse_charset_from_content_type(content_type)
if (content_type && content_type.length > 0)
charset = content_type.split(';').delete_if { |attribute| !attribute.lstrip.start_with?('charset=') }.map { |x| x.lstrip }[0]
charset['charset='.length...charset.length] if charset
end
end
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I guess add a code comment to briefly explain this
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I added a comment!
I added an integration spec for AzureRM, and I got results as below with my Azure account.
|
Will release next week (or you can try |
I added AzureRM provider to support Azure Blob storage. It depends on fog-azure-rm gem.