使用 rails 回形针插件将图像存储在数据库中 [英] Store image in database using rails paperclip plugin

查看:33
本文介绍了使用 rails 回形针插件将图像存储在数据库中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个使用 Paperclip 插件上传图片的应用程序.现在该应用程序应该部署到具有只读文件系统的主机(heroku).我可以以某种方式告诉回形针将图像存储在数据库中吗?

I have an application that uses the Paperclip plugin for image upload. Now that app should get deployed to an host(heroku) which has a read-only file system. Can I somehow tell paperclip to store the images in the database?

推荐答案

查看此示例应用

http://patshaughnessy.net/2009/5/29/paperclip-sample-app-part-3-saving-file-attachments-in-a-database-blob-column

我想这正是您所需要的.

I guess this is exactly what you need.

HTH

PS:在 db 中存储图像通常是一个坏主意,我相信您可以将回形针与 S3/cloudfront 一起使用(如下面的答案中所述)

PS: storing images in db is usually a bad idea, I am sure you can use paperclip with S3 / cloudfront ( as mentioned in the answers below )

这篇关于使用 rails 回形针插件将图像存储在数据库中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆