Skip to content

forked middleware (don't remember which origin) layer for gridfs

License

Notifications You must be signed in to change notification settings

bulters/rack-gridfs

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

29 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Rack::GridFS

Rack:GridFS is a Rack middleware for creating HTTP endpoints for files stored in MongoDB’s GridFS. You can configure a prefix string which will be used to match the path of a request and supply an id for looking up the file in the GridFS store.

For example,

GET '/gridfs/someobjectid'

If the prefix is “gridfs”, then the id will be be “someobjectid”.

Mongo Driver Compatibility Notes

This version is currently based on mongo-1.1+. As there were significant changes to the GridFS API prior to v1.0, you may have luck with the git-tagged version 0.2.0 of this library with earlier versions of the driver.

Installation

gem install rack-gridfs

Usage

require 'rack/gridfs'
use Rack::GridFS, :hostname => 'localhost', :port => 27017, :database => 'test', :prefix => 'gridfs'

You must specify MongoDB database details:

  • hostname: the hostname/IP where the MongoDB server is running. Default ‘localhost’.

  • port: the port of the MongoDB server. Default 27017.

  • database: the MongoDB database to connect to.

  • prefix: a string used to match against incoming paths and route to through the middleware. Default ‘gridfs’.

Sinatra Example

# TODO: THIS COULD USE A LOT MORE EXPLANATION!

require 'rubygems'
require 'sinatra'

require 'rack/gridfs'
use Rack::GridFS, :hostname => 'localhost', :port => 27017, :database => 'test', :prefix => 'gridfs'

get /.*/ do
  "The URL did not match a file in GridFS."
end

Copyright © 2010 Blake Carlson. See LICENSE for details.

About

forked middleware (don't remember which origin) layer for gridfs

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 4

  •  
  •  
  •  
  •  

Languages