Back

Explore Courses Blog Tutorials Interview Questions
0 votes
2 views
in AWS by (19.1k points)

I have an application which is deployed to Heroku using amazon s3 posting images to buckets. This works perfectly fine. But when fetching the same image it gives an error:

Errno::ENOENT (No such file or directory showing path s3.amazonaws.com/bucket_name/app/public/messages/images/000/000/061/thumb/images.jpeg?1362410115)

Same path copying and pasting in the browser's URL doesn't work. If I am using bucket name as endpoint it works ie, with the following path

/bucket_name.s3.amazonaws.com/app/public/messages/images/000/000/061/thumb/images.jpeg?1362410115.

But I don't know how to configure this URL in my model. I am following Heroku's way to configure aws-sdk.

 https://devcenter.heroku.com/articles/paperclip-s3

The model has_attached_file seems like I am missing something here. For the rest of the configuration, you can check the above link.

has_attached_file :image, :styles => { :medium => "100x100>", :thumb => "100x100>" }

1 Answer

0 votes
by (44.4k points)

Adding this code in config/initializers/paper_clip.rb solved the issue.

    Paperclip::Attachment.default_options.merge!(

        :url => ':s3_domain_url',

        :path => 'app/public/:class/:attachment/:id_partition/:style/:filename'

    )

Related questions

Want to get 50% Hike on your Salary?

Learn how we helped 50,000+ professionals like you !

0 votes
1 answer

Browse Categories

...