-
Notifications
You must be signed in to change notification settings - Fork 282
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
ActiveStorage Mirror Issue #562
Comments
@airjoshb , thank you for reporting the issue! This is indeed weird. Did it happen in the previous version of the SDK, for example: 2.1.2 ? In the latest version we added explicit In addition you can also try to pass
|
Thanks for getting back to me. I hadn't tried this particular setup in the previous SDK. I'll try downgrading and see if that works. I have another project that could be on the older SDK and that works flawlessly, which is why I have been so stumped! I did try setting everything in the storage.yml with the same effect. One difference I noticed between the two in calling the config is that in the working project, there is no false=false, which shows up no matter how I configure in the newer setup ... maybe a hint?
|
@airjoshb when setting those values in |
@airjoshb I was able to setup the mirror storage, set a few different cloudinary configurations in
And both worked for me. |
Ok- I was able to get the direct mirroring to work using the storage.yml configuration. The point of setting this up was to migrate from S3 to Cloudinary and so I was using the mirror_later feature of active storage to accomplish this, but I get the same error for cloud_name when I run it. Current status:
And to ensure clarity, I am passing the cloud_name in the storage.yml, per your original comment. Thanks for all the help! |
hi @const-cloudinary - any additional thoughts on this? |
Hey @airjoshb , There are actually 2 ways configuring Cloudinary using env variables, using
I would check |
Thanks, @const-cloudinary This all feels quite strange, as I am now getting an error: Cloudinary::BaseApi::AuthorizationRequired: unknown api_key I have taken your advice and set up env variables two different ways to see if it would make a difference, one with all of the ENV variables separate
and get the proper keys, matching up to the API keys in the console
Running mirror_later, the job is now enqueued successfully
but when the job runs I get, Cloudinary::BaseApi::AuthorizationRequired: unknown api_key I get the same error if setting up using CLOUDINARY_URL
I was thinking that perhaps the key wasn't working, but the uploading works directly in the mirror. Thanks for your patience and help! |
@airjoshb, this is really strange. One thing I can think of is that maybe Maybe try overriding the default class ActiveStorage::MirrorJob < ApplicationJob
queue_as :default
def perform(blob, attachable)
# Custom behavior for mirroring
Rails.logger.info "Custom MirrorJob: Starting mirroring for #{blob.key}"
Cloudinary.config do |config|
config.cloud_name = ENV['CLOUDINARY_CLOUD_NAME']
config.api_key = ENV['CLOUDINARY_API_KEY']
config.api_secret = ENV['CLOUDINARY_API_SECRET']
end
# Call the original mirroring process
super if defined?(super)
end
end Or just print variables and check what you see there. Another way would be to override module ActiveStorage
class Service::CustomCloudinaryService < Service::CloudinaryService
def initialize(**options)
# Explicitly set @options to include credentials
@options = options.merge({
cloud_name: ENV['CLOUDINARY_CLOUD_NAME'],
api_key: ENV['CLOUDINARY_API_KEY'],
api_secret: ENV['CLOUDINARY_API_SECRET'],
secure: true # or any other Cloudinary settings you want to configure
})
# Call the original initializer to make sure CloudinaryService is set up properly
super(**@options)
end
end
end and then in your
Similarly you can modify
or other methods and pass credentials explicitly. Please let me know if it works for you. |
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
In an initializer, cloudinary.rb where the env includes the key:key@cloud_name format
And, my storage.yml is super simple, as the gem seems to prefer using the initializer
The text was updated successfully, but these errors were encountered: