-
Notifications
You must be signed in to change notification settings - Fork 284
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
Invalid Remote Fetch URL if folder
is set in Storage Service Config
#537
Comments
Hi @brendanmatkin, The cl_image_tag method described above generates an HTML image tag. In certain conditions, you might want to generate a transformation URL directly, without the containing image tag. To return only the URL, either use the cl_image_path or cloudinary_url view helper methods, or use the Ruby command: I hope you find it useful. Regards, |
Thanks @wissam-khalili. My above issue is true for those commands ( The Storage Service Config The only way to make it work is to build the url manually. The bug still exists though even though the workaround is documented. Here is my manual URL builder if anyone else has the same problem (obviously the transformations are specific to my use case and URL signing is enabled). def cloudinary_url_manual(url, width, height)
transformation = "c_lfill,h_#{height},w_#{width}/q_auto/f_auto"
public_id = escape(url) # can prepend with folder if using
to_sign = [transformation, public_id].join("/")
secret = Rails.application.credentials.dig(:cloudinary, :api_secret)
signature = "s--#{Base64.urlsafe_encode64(Digest::SHA1.digest(to_sign + secret))[0, 8]}--"
cloud_name = Rails.application.credentials.dig(:cloudinary, :cloud_name)
"https://res.cloudinary.com/#{cloud_name}/image/fetch/#{[signature, to_sign].join('/')}"
end
def escape(url)
url.gsub("?", "%3F").gsub("&", "%26").gsub("=", "%3D")
end |
@brendanmatkin there are actually 2 cloudinary_gem/lib/cloudinary/helper.rb Line 235 in 088330b
And another one is here: cloudinary_gem/lib/cloudinary/utils.rb Line 882 in 088330b
The latter one should be good for building fetch URLs. |
@const-cloudinary ah ok! I'm still getting the hang of Ruby/Rails, and I'm not sure if I realized I could use the I THINK we tried the second one at some point, but I can't be sure (it might've been under different circumstances - there are 2 apps that use Cloudinary remote fetch). Thanks for clarifying either way! I will try this again soon - hopefully that was my issue. |
p.s. @wissam-khalili thanks also for your help - I misinterpreted that you were showing me 2 different cloudinary_url methods. Along these same lines, should the non-utility method still be able to work with remote fetch? It seems to take the option, but it definitely doesn't work. If so, this could still be a valid bug, right? |
Hi @brendanmatkin, Thank you for your feedback. Thanks, |
Ok sounds good! Thanks for the engagement and help so far. |
Hi @brendanmatkin , Please note that this issue was fixed. |
@wissam-khalili Nice, thanks for updating me!! Appreciate y'all getting on this obscure bug. |
Bug report for Cloudinary Ruby SDK
Describe the bug in a sentence or two.
For a remote fetch,
cloudinary_url
andcl_image_path
output URL has versionv1
and<folder>
prepended to the publicID, if folder is set in storage.yml. If no folder is set, output URL works as expected.It's possible that there is an option I can't figure out that helps with this? If so, maybe a documentation issue?
Issue Type (Can be multiple)
Steps to reproduce
config/environment/<env>.rb
has line:config.active_storage.service = :cloudinary
Error screenshots or Stack Trace (if applicable)
Operating System
(probably all but only tested with these two)
Environment and Libraries (fill in the version numbers)
The text was updated successfully, but these errors were encountered: