I'm using refile gem for file uploading and I'm uploading files directly to my amazon s3 public bucket. The files are being uploaded just fine to following URL:
https://s3.amazonaws.com/{bucket-name}/store/6309035935359dca1ef549170e7facac9ab3553ad53946cea0bcb8335475
I'm using amazon cloudfront to serve these assets from s3, so the cloudfront url, for the asset given above, is something like this:
https://{distribution-name}.cloudfront.net/store/6309035935359dca1ef549170e7facac9ab3553ad53946cea0bcb8335475
The both urls when accessed directly through browser works fine. To display this asset in my app view file I'm using refile gem following helper function:
attachment_image_tag(@post, :profile_img, :fill, 350, 350)
Now the issue is, this helper method prints a URL something like this:
https://{distribution-name}.cloudfront.net/attachments/5845d0a97dc77a57b5b05742a1eb26d629d7cdaa/store/fill/350/350/6309035935359dca1ef549170e7facac9ab3553ad53946cea0bcb8335475/file
As this URL is different from above cloudfront URL, it is not displaying the image. How do I force attachment_image_tag
function to print the correct cloudfront URL?