简体   繁体   中英

Storing Images in Postgres DB Store RefineryCMS with Dragonfly

My application is a refineryCMS which is been hosted on the heroku server . I need to store the images on the postgres DB store. I got one gem dragonfly-activerecord , but not able to keep it on database . I tried:

Configure Dragonfly itself (in config/initializers/dragonfly.rb , typically):

require 'dragonfly-activerecord/store'

Dragonfly.app.configure do
 # ... your existing configuration here
 datastore Dragonfly::ActiveRecord::Store.new

We need to integrate this gem into refineryCMS.. If we can store images in database for cms that will be great help for host like heroku.

Why don't you just use Amazon S3 to store images? It works great with Heroku : http://www.refinerycms.com/guides/heroku

Here is a solution along with the dragonfly-activerecord fork . Just go to config/initializers/refinery/images.rb Here is a code to do it. First follow dragonfly-activerecord fork steps

In Gemfile:

gem 'dragonfly-activerecord' , git: "git://github.com/arpit-clarion/dragonfly-activerecord.git" and

bundle

rails generate migration add_dragonfly_storage

In the migration file add this code

require 'dragonfly-activerecord/migration'

class AddDragonflyStorage < ActiveRecord::Migration
  include Dragonfly::ActiveRecord::Migration
end

Run rake db:migrate and add this code:

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

This will change the whole system folder structure set into database. No need to any buckets .

Keep in mind that this system is for those applications which has less images to store as it generates big chunks in db and it converts images on request time.

Awesome! Could you write this solution as a guide in Refinery CMS repository? https://github.com/refinery/refinerycms/tree/master/doc/guides

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM