Paperclip Azure Storage
Description
paperclip-azure-storage
is a paperclip adapter for azure storage.
The difference between this and other azure adapter, such as paperclip-azure, was the ability to use service principal as the authentication method.
Getting Started
- Add
paperclip-azure-storage
onGemfile
gem 'paperclip-azure-storage'
- Configure
paperclip
require 'paperclip-azure-storage'
Paperclip::DataUriAdapter.register
Paperclip::Attachment.default_options[:storage] = :azure_storage
Paperclip::Attachment.default_options[:tenant_id] = 'c881ddef-bf33-4574-a43b-1876a94c940a'
Paperclip::Attachment.default_options[:client_id] = 'e35cf4da-b3cd-4722-9923-deed0bf41a37'
Paperclip::Attachment.default_options[:client_secret] = 'J@NcRfUjXn2r5u7x!A%D*G-KaPdSgVkY'
Paperclip::Attachment.default_options[:resource] = 'https://mystorage.blob.core.windows.net'
Paperclip::Attachment.default_options[:storage_name] = 'mystorage'
Paperclip::Attachment.default_options[:container] = 'mycontainer'
- Upload & access your image
image_content = '<some-image>'
model = model_class.create!(image: image_content) # upload image to azure
model.image.azure_url # get azure image url