Easiest way to store images in database on Heroku?

后端 未结 2 1378
暖寄归人
暖寄归人 2021-02-09 18:42

We have a RoR 3.2 site on Heroku using their production tier PostgreSQL database.

Our site users occasionally upload images of 0.5 - 2MB in size. For different reasons

2条回答
  •  北荒
    北荒 (楼主)
    2021-02-09 19:06

    I encourage you to not use your database to store images of that size.

    S3 can be backed up very effectively, and is extremely hardened. From a data loss perspective, it's effectively safer then a development postgres database plan with Heroku.

    The cost aspect is also not really best practice in this example. Although you're right they only enforce a row limit, I think it would be frowned upon to store large images (0.5 - 2mb) in the development database plan.

    Finally, the speed of a transfer to S3 from EC2 (where Heroku is hosted) is very fast due to Amazon's internal networking.

    Knowing that, I'd urge you to rethink your desire to store images of that size in a database. See this question for a more in depth analysis on the pros and cons.

    There's also a dev center article about using S3 and Heroku.

提交回复
热议问题