cloudinary_gem icon indicating copy to clipboard operation
cloudinary_gem copied to clipboard

ActiveStorage Mirror Issue

Open airjoshb opened this issue 4 months ago • 9 comments

I am trying to set up ActiveStorage mirror so that I can migrate from S3 into my Cloudinary. When I try to run the mirror check and upload, I'm getting an error, "RuntimeError (Must supply cloud_name)"

If I check Cloudinary.config, I get all the correct info: #<OpenStruct cloud_name="airjoshb", api_key="my_key", api_secret="my_key", private_cdn=false, false=false, secure=true, enhance_image_tag=true, static_file_support=false>

But if I check Cloudinary.config.cloud_name, it returns false

If I try to run the mirror command locally, I get a bit more info in that it is confirming the file isn't in my mirror on Cloudinary Cloudinary Storage (4.0ms) Checked if file exists at key: 3uxbbrz9kh4mw7iq2z2xzyuo1w2z (no) Mirror Storage (4.5ms) Mirrored file at key: 3uxbbrz9kh4mw7iq2z2xzyuo1w2z (checksum: DSAVwrDMF+tj9ncc9pCX2A==) /Users/joshua/.rbenv/versions/3.0.0/lib/ruby/gems/3.0.0/gems/cloudinary-2.2.0/lib/cloudinary/api.rb:1269:in call_api': Must supply cloud_name (RuntimeError)`

Any thoughts on why it finds the cloud_name but is returning false when I try to use it?

ruby 3.0.0p0 Rails 7.0.4 cloudinary (2.2.0) activestorage (7.0.4)

I have tried all manner of configurations, using the cloudinary.yml in the config folder

development:
    cloud_name: airjoshb
    api_key: ENV.fetch('CLOUDINARY_KEY_ID')
    api_secret: ENV.fetch('CLOUDINARY_ACCESS_KEY')
    enhance_image_tag: true
    static_file_support: false

  production:
    cloud_name: airjoshb
    api_key: ENV.fetch('CLOUDINARY_KEY_ID')
    api_secret: ENV.fetch('CLOUDINARY_ACCESS_KEY')
    enhance_image_tag: true
    static_file_support: true

In an initializer, cloudinary.rb where the env includes the key:key@cloud_name format

require 'cloudinary'

Cloudinary.config_from_url("cloudinary://ENV.fetch('CLOUDINARY_URL')")
Cloudinary.config do |config|
  config.secure = true
  config.enhance_image_tag = true
  config.static_file_support= false
end

And, my storage.yml is super simple, as the gem seems to prefer using the initializer

cloudinary:
  service: Cloudinary
  folder: switch-bakery

# Use bin/rails credentials:edit to set the AWS secrets (as aws:access_key_id|secret_access_key)
amazon:
  service: S3
  access_key_id:     <%= ENV.fetch('AWS_ACCESS_KEY_ID') %>
  secret_access_key: <%= ENV.fetch('AWS_SECRET_ACCESS_KEY') %>
  region:            'us-west-1'
  bucket: <%= ENV.fetch('S3_BUCKET_NAME') %>

production:
  service: Mirror
  primary: amazon
  mirrors:
    - cloudinary

airjoshb avatar Sep 30 '24 20:09 airjoshb