amazon web services - Rails Paperclip Heroku AWS DIsplay Image issue -
i set paperclip in rails app , worked fine locally , on heroku, images uploaded in posts saved in heroku short space of time. set aws account , created bucket, , followed through documentation link rails app aws display images uploaded paperclip. have attached code snippets below. images seem uploaded aws fine, when create post, says post has been created successfully, image not display, displays broken link. when click image properties, hs aws s3 url , upon looking in heroku logs, there no known issues. not know why image not displaying.
config/environments/production.rb file:
# sets paperclip upload images amazon s3 # variables directed heroku via command line pw etc config.paperclip_defaults = { storage: :s3, s3_credentials: { bucket: env.fetch('s3_bucket_name'), access_key_id: env.fetch('aws_access_key_id'), secret_access_key: env.fetch('aws_secret_access_key'), s3_region: env.fetch('aws_region'), } }
post.rb model file:
class post < applicationrecord extend friendlyid friendly_id :title, use: [:slugged, :finders] has_attached_file :image, styles: { medium: "600x", thumb: "100x" } validates_attachment_content_type :image, content_type: /\aimage\/.*\z/ end
show.html.erb file:
<div class="image"> <%= image_tag @post.image.url(:medium) %> </div>
i have set heroku correctly using following:
$ heroku config:set s3_bucket_name=your_bucket_name $ heroku config:set aws_access_key_id=your_access_key_id $ heroku config:set aws_secret_access_key=your_secret_access_key $ heroku config:set aws_region=your_aws_region
any appreciated.
many thanks
as per judd's answer paperclip, s3, heroku: missing image, because needed state s3_host_name in paperclip default settings:
# sets paperclip upload images amazon s3 # variables directed heroku via command line pw etc config.paperclip_defaults = { storage: :s3, s3_host_name: 's3-eu-west-1.amazonaws.com', s3_credentials: { bucket: env.fetch('s3_bucket_name'), access_key_id: env.fetch('aws_access_key_id'), secret_access_key: env.fetch('aws_secret_access_key'), s3_region: env.fetch('aws_region'), }
Comments
Post a Comment