I use Paperclip. In development everything is ok, but on Heroku I add images to posts, at first everything is fine - everything loads and shows, but after a while all the images disappear - in their place only the file names. What could be the problem?

Heroku logs shows something about problems with paths:

2016-05-13T14:38:05.031223+00:00 heroku[router]: at=info method=GET path="/system/posts/images/000/000/007/medium/app-server-arena2.png?1463131430" host=arcane-taiga-31170.herokuapp.com request_id=21181509-0382-494c-b4d8-fc0837464c99 fwd="92.100.233.26" dyno=web.1 connect=0ms service=4ms status=404 bytes=1789 2016-05-13T14:38:05.029499+00:00 app[web.1]: ActionController::RoutingError (No route matches [GET] "/system/posts/images/000/000/007/medium/app-server-arena2.png"): 2016-05-13T14:38:05.027456+00:00 app[web.1]: Started GET "/system/posts/images/000/000/007/medium/app-server-arena2.png?1463131430" for 92.100.233.26 at 2016-05-13 14:38:05 +0000 

    1 answer 1

    Yes, Heroku works that way.

    The local disk is "ephemeral" and can be recreated from the image at any time. Namely, when the application “falls asleep”, its disk is destroyed, and when it is “awakened”, a new, separate for each type of machine (dyno) is created. Therefore, the disk nothing that is intended for long-term storage, can not be saved.

    You need to use external storage. You can save directly to the database (they are not intended for this, but in theory this is real), and you can connect an external storage service with HTTP access like the Amazon Simple Storage Service (S3), or you can invent / find something else.

    • I looked through the options of S3, Google and a couple more, but they all require you to enter credit card details. I would like to avoid this, because There is an experience of charging hidden fees. You do not know any services with paperclip binding without entering a credit card at first? - lif3ar
    • @ lif3ar right there is no paperclip itself, but anything will suit you, which provides disk space and gives access via a protocol that paperclip can be taught. FTP though. But in general, disk space for obvious reasons costs money :) And in the West, they are much more serious attitude. - D-side
    • Understood, thanks, I'll try to fill in with FTP. I agree, it costs money, but Amazon writes that it unilaterally begins to write off money from the card when the quota is increased, and I have started to receive 1.5-2000 requests every day for several months every day for several months through garbage resources. - lif3ar
    • one
      @ lif3ar expenses for such accidents can be reimbursed , but it’s not worth counting on, yes. - D-side