I have a Rails app with ActionText and ActiveStorage. So I have a ticket form with a description field, where ActionText is used. When I have the development environment configured to save the attachments to the local disk, everything works fine.
But when I configure it to use Azure storage, I see in the log that it seems to have uploaded (it returns an URL), but when I look in Azure, there is no stored image. This is the log:
Started POST "/rails/active_storage/direct_uploads" for ::1 at 2019-07-30 08:05:37 +0200
Processing by ActiveStorage::DirectUploadsController#create as JSON
Parameters: {"blob"=>{"filename"=>"schaap.jpg", "content_type"=>"image/jpeg", "byte_size"=>56679, "checksum"=>"xNr4chw64aFTDzzvpmupBg=="}, "direct_upload"=>{"blob"=>{"filename"=>"schaap.jpg", "content_type"=>"image/jpeg", "byte_size"=>56679, "checksum"=>"xNr4chw64aFTDzzvpmupBg=="}}}
(0.2ms) BEGIN
ActiveStorage::Blob Create (0.8ms) INSERT INTO "active_storage_blobs" ("key", "filename", "content_type", "byte_size", "checksum", "created_at") VALUES ($1, $2, $3, $4, $5, $6) RETURNING "id" [["key", "p83x87l66oibofrfmitfiqet120d"], ["filename", "schaap.jpg"], ["content_type", "image/jpeg"], ["byte_size", 56679], ["checksum", "xNr4chw64aFTDzzvpmupBg=="], ["created_at", "2019-07-30 06:05:38.851532"]]
(0.6ms) COMMIT
AzureStorage Storage (0.9ms) Generated URL for file at key: p83x87l66oibofrfmitfiqet120d (https://<blob name>.blob.core.windows.net/<container-name>/p83x87l66oibofrfmitfiqet120d?sp=rw&sv=2016-05-31&se=2019-07-30T06%3A10%3A38Z&sr=b&sig=%2BicDHTsLBXWCIr00m4cbmcg3U6il5LMfhVcKwTq8dns%3D)
Completed 200 OK in 867ms (Views: 0.4ms | ActiveRecord: 5.7ms | Allocations: 70289)
This is in config/development.rb
:
config.active_storage.service = :local
And this is in storage.yml
:
local:
service: AzureStorage
storage_account_name: "<account-name>"
storage_access_key: "<access-key>"
container: "<container>"
And the proper gem is used:
gem 'azure-storage', require: false
So what is wrong? I tried the same with Digital Ocean spaces, but with the exact same result, so it is not Azure related.