2012-07-23 06:29:15 +00:00
|
|
|
NAME
|
|
|
|
----
|
|
|
|
mongoid_grid_fs
|
|
|
|
|
2012-07-23 06:31:01 +00:00
|
|
|
INSTALL
|
|
|
|
-------
|
|
|
|
gem install mongoid_grid_fs
|
|
|
|
|
2012-07-23 06:29:15 +00:00
|
|
|
SYNOPSIS
|
|
|
|
--------
|
|
|
|
|
2012-07-23 06:31:01 +00:00
|
|
|
````ruby
|
2012-07-23 06:29:15 +00:00
|
|
|
|
2012-07-23 06:31:01 +00:00
|
|
|
require 'mongoid-grid_fs'
|
2012-07-23 06:29:15 +00:00
|
|
|
|
2012-07-23 06:31:28 +00:00
|
|
|
g = GridFs.put readable
|
2012-07-23 06:29:15 +00:00
|
|
|
|
2012-07-23 06:31:01 +00:00
|
|
|
GridFS.get id
|
2012-07-23 06:29:15 +00:00
|
|
|
|
2012-07-23 06:31:01 +00:00
|
|
|
GridFS.delete id
|
2012-07-23 06:29:15 +00:00
|
|
|
|
|
|
|
|
2012-07-23 06:31:01 +00:00
|
|
|
````
|
2012-07-23 06:29:15 +00:00
|
|
|
|
|
|
|
DESCRIPTION
|
|
|
|
-----------
|
2012-07-23 06:32:55 +00:00
|
|
|
mongoid_grid_fs is a pure mongoid 3 / moped implementation of the mongodb
|
2012-07-23 06:31:01 +00:00
|
|
|
grid_fs specification
|
2012-07-23 06:29:15 +00:00
|
|
|
|
2012-07-23 06:31:01 +00:00
|
|
|
ref: http://www.mongodb.org/display/DOCS/GridFS+Specification
|
2012-07-23 06:29:15 +00:00
|
|
|
|
2012-07-23 06:31:01 +00:00
|
|
|
it has the following features:
|
2012-07-23 06:29:15 +00:00
|
|
|
|
2012-07-23 06:34:29 +00:00
|
|
|
- implementation is on top of mongoid for portability. moped (the driver) is
|
|
|
|
barely used
|
2012-07-23 06:29:15 +00:00
|
|
|
|
2012-07-23 06:31:01 +00:00
|
|
|
- simple, REST-like api
|
2012-07-23 06:29:15 +00:00
|
|
|
|
2012-07-23 06:31:01 +00:00
|
|
|
- support for custom namespaces (fs.files vs. image.files)
|
2012-07-23 06:29:15 +00:00
|
|
|
|
2012-07-23 06:31:01 +00:00
|
|
|
- pathnames and io-like objects can be written to the grid
|
2012-07-23 06:29:15 +00:00
|
|
|
|
2012-07-23 06:31:01 +00:00
|
|
|
- auto-unique pathnames are generated (by default) to avoid collisions using #put
|
2012-07-23 06:29:15 +00:00
|
|
|
|
2012-07-23 06:31:01 +00:00
|
|
|
'path/info/a.rb' -> '$object_id/a.rb'
|
2012-07-23 06:29:15 +00:00
|
|
|
|
2012-07-23 06:31:51 +00:00
|
|
|
- [] and []= methods which allow the grid to be used like a giant file
|
2012-07-23 06:31:01 +00:00
|
|
|
hash in the sky
|
2012-07-23 06:29:15 +00:00
|
|
|
|
2012-07-23 06:31:01 +00:00
|
|
|
- supprt for data_uris
|
2012-07-23 06:29:15 +00:00
|
|
|
|
2012-07-23 06:32:10 +00:00
|
|
|
````erb
|
2012-07-23 06:29:15 +00:00
|
|
|
|
2012-07-23 06:32:35 +00:00
|
|
|
<%= image_tag :src => file.data_uri %>
|
2012-07-23 06:29:15 +00:00
|
|
|
|
2012-07-23 06:31:01 +00:00
|
|
|
````
|