mihaic195 said almost 3 years ago on Active Storage Uploads Behind a CDN :
Doesn't seem to be working for variants... but for regular ActiveStorage it's fine.

David Kimura PRO said almost 3 years ago on Active Storage Uploads Behind a CDN :
  Do you see any errors in the console? What isn't working? Are you getting errors and the image won't display? You may need to install the imagemagick library for the variants.

mihaic195 said almost 3 years ago on Active Storage Uploads Behind a CDN :
  with Variants, the link looks like this:  
variants/rsoao6al0qs6i7ufbzm5x2nw4hr1/cabe6e2a3218e12456787572cfb5ee71459383cdd72e19a0f5bacea3b3987208
which yields a 403 from Cloudfront. 
I have the image_processing gem installed.

David Kimura PRO said almost 3 years ago on Active Storage Uploads Behind a CDN :
  On, S3, can you verify within the bucket that the variant was created?

David Kimura PRO said almost 3 years ago on Active Storage Uploads Behind a CDN :
Also, try adding this to the CORS Configuration within the S3 Bucket



<?xml version="1.0" encoding="UTF-8"?>
<CORSConfiguration xmlns="http://s3.amazonaws.com/doc/2006-03-01/">
<CORSRule>
    <AllowedOrigin>*</AllowedOrigin>
    <AllowedMethod>GET</AllowedMethod>
    <AllowedMethod>HEAD</AllowedMethod>
    <AllowedHeader>*</AllowedHeader>
</CORSRule>
</CORSConfiguration>

After a few minutes, if you find this working, you can then start narrowing down the CORS rules if needed. 

mihaic195 said almost 3 years ago on Active Storage Uploads Behind a CDN :
Indeed the variants are missing from S3

David Kimura PRO said almost 3 years ago on Active Storage Uploads Behind a CDN :
That's strange. Check your application logs to see what's going on.

mihaic195 said almost 3 years ago on Active Storage Uploads Behind a CDN :
Based on the Rails Documentation from https://api.rubyonrails.org/classes/ActiveStorage/Variant.html
all I had to do is call processed on the image to create the variant, which is still weird to me. Now the CDN link also works.
Thank you!

<%= image_tag cdn_url(@user.avatar.variant(resize_to_limit: [100, 100]).processed)

Login to Comment