Sha256: edc6bb0f6ef92d3c39b3a8636d10d4f664a57fdde086779cfb6b1d75b6514605
Contents?: true
Size: 824 Bytes
Versions: 2
Compression:
Stored size: 824 Bytes
Contents
module MixRailsCore module Gridfs mattr_accessor :read_file def self.read_file(filepath) gridfs_path = filepath.gsub("/system/", "") database_name = Mongoid::Config.sessions[:default][:database] host_and_port = Mongoid::Config.sessions[:default][:hosts][0].split(':') host = host_and_port[0] port = host_and_port[1] username = Mongoid::Config.sessions[:default][:username] password = Mongoid::Config.sessions[:default][:password] con = Mongo::MongoClient.new(host, port) if username con.add_auth(database_name, username, password) end db = con.db(database_name) gridfs_file = Mongo::GridFileSystem.new(db).open(gridfs_path, 'r') gridfs_file end end end
Version data entries
2 entries across 2 versions & 2 rubygems
Version | Path |
---|---|
mix-rails-0.22.0 | mix-rails-core/lib/mix-rails-core/gridfs.rb |
mix-rails-core-0.22.0 | lib/mix-rails-core/gridfs.rb |