我的应用程序是一个refineryCMS,它托管在heroku服务器上。我需要将图像存储在postgres存储上。我有一个创业板蜻蜓-活动兽,但不能保存在数据库中。我试过:
配置蜻蜓本身(通常在config/initializers/dragonfly.rb
中):
require 'dragonfly-activerecord/store'
Dragonfly.app.configure do
# ... your existing configuration here
datastore Dragonfly::ActiveRecord::Store.new
我们需要将这个宝石集成到refineryCMS中。如果我们能够将图像存储在数据库中用于cms,这将对像heroku这样的主机有很大的帮助。
发布于 2016-06-10 03:54:53
以下是与蜻蜓-活动叉一起的解决方案。只需转到config/initializers/refinery/images.rb
,这里就有一个代码来完成它。首先遵循蜻蜓-活动叉步骤
在Gemfile中:
gem 'dragonfly-activerecord' , git: "git://github.com/arpit-clarion/dragonfly-activerecord.git"
和
bundle
rails generate migration add_dragonfly_storage
在迁移文件中添加以下代码
require 'dragonfly-activerecord/migration'
class AddDragonflyStorage < ActiveRecord::Migration
include Dragonfly::ActiveRecord::Migration
end
运行rake db:migrate
并添加以下代码:
config/initializers/refinery/images.rb
# encoding: utf-8
require 'dragonfly-activerecord/store'
Refinery::Images.configure do |config|
#...... Your configuration ....
config.custom_backend_class = 'Dragonfly::ActiveRecord::Store'
config.custom_backend_opts = {}
#...... Your configuration ....
end
这将将整个系统文件夹结构设置为数据库。不需要任何桶。
请记住,该系统适用于那些在db中生成大块的映像较少存储的应用程序,并根据请求时间转换图像。
发布于 2016-06-08 07:22:01
你为什么不直接使用亚马逊S3来存储图像呢?它非常适合Heroku:http://www.refinerycms.com/guides/heroku
发布于 2016-06-15 11:10:32
太棒了!你能把这个解决方案写成精炼厂CMS库的指南吗?https://github.com/refinery/refinerycms/tree/master/doc/guides
https://stackoverflow.com/questions/37696397
复制相似问题