Carrierwave::AzureRM
Microsoft Azure Storage blob support for CarrierWave.
Heavily inspired by @unosk carrierwave-azure gem, which seems to be no longer maintained.
Uses new azure-storage sdk to support ARM.
Installation
Add this line to your application's Gemfile:
gem 'carrierwave-azure_rm'
And then execute:
$ bundle
Usage
First configure CarrierWave with your Azure storage credentials
CarrierWave.configure do |config|
config.azure_storage_account_name = 'YOUR STORAGE ACCOUNT NAME'
config.azure_storage_access_key = 'YOUR STORAGE ACCESS KEY'
config.azure_storage_blob_host = 'YOUR STORAGE BLOB HOST' # optional
config.azure_container = 'YOUR CONTAINER NAME'
config.asset_host = 'YOUR CDN HOST' # optional
end
And then in your uploader, set the storage to :azure_rm
class ExampleUploader < CarrierWave::Uploader::Base
storage :azure_rm
end
Private blobs
If your container access policy is set to private, carrierwave-azure_rm can automatically return signed urls on the files. Enable auto_sign in the configuration:
config.auto_sign_urls = true
config.token_expire_after = 3600 # optional - Set the expire time of the url to 3600 seconds. Default is 1800 seconds
If you wish a newly created container to be initialized with a specific access_level you can set the following in your config:
config.public_access_level = 'private' # optional - possible values are blob, private, container
This config is only required if your container does not exist and you want it to be configured automatically.
Issues
If you have any problems with or questions about this image, please contact me through a GitHub issue.
Contributing
You are invited to contribute new features, fixes, or updates, large or small.
I'm always thrilled to receive pull requests, and do my best to process them as fast as I can.
In order to run the integration specs you will need to configure some environment variables.
A sample file is provided as spec/environment.rb.sample
.
Copy it over and plug in the appropriate values.
cp spec/environment.rb.sample spec/environment.rb
- Fork it
- Create your feature branch (
git checkout -b my-new-feature
) - Commit your changes (
git commit -am 'Add some feature'
) - Push to the branch (
git push origin my-new-feature
) - Create new Pull Request
License
Released under the MIT License. See LICENSE file for details.