MiH
MiH

Reputation: 421

Heroku error when using Paperclip gem in rails 4

My project is about an online Shopping site. I use paperclip gem to updload image. My problem is: I can upload images,show them.But after 4-5 hours it cant show image.It doesn't images. What should I do to save Images all time ?

Upvotes: 0

Views: 53

Answers (2)

NM Pennypacker
NM Pennypacker

Reputation: 6952

Heroku deletes files in your public folder every time it instantiates a new VM (usually after your app has been dormant for a few minutes.)

You need to store your images in a place where they will persist when a VM is destroyed. Heroku has a tutorial on how to store the files at S3 here:

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

Upvotes: 1

Ho Man
Ho Man

Reputation: 2345

  • Sign up for an AWS S3 account. (Its really cheap within normal usage imo)
  • Use Fog. There is a guide here.
  • Sign the S3 image urls when serving to frontend, to expire in 4-5 hours.

Upvotes: 0

Related Questions