Skip to content
This repository


Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Rack middleware for adding HTTP endpoints for files stored in MongoDB GridFS

tag: v0.1.0

Fetching latest commit…


Cannot retrieve the latest commit at this time

Octocat-spinner-32 example Created a simple Sinatra app to play with the GridFS middleware. September 20, 2009
Octocat-spinner-32 lib
Octocat-spinner-32 test
Octocat-spinner-32 .gitignore
Octocat-spinner-32 LICENSE
Octocat-spinner-32 README.rdoc
Octocat-spinner-32 Rakefile
Octocat-spinner-32 VERSION
Octocat-spinner-32 rack-gridfs.gemspec


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 create a key for looking up the file in the GridFS store.

For example,

GET '/gridfs/images/foo.jpg'

If the prefix is “gridfs”, then the key will be be “images/foo.jpg”.


  • ActiveSupport (activesupport)

  • Mongo Ruby Driver (mongodb-mongo)


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

require 'rubygems'
require 'sinatra'

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

get /.*/ do
  "Whatchya talking about?"


  • Make it awesome.

  • What's up with the performance?

  • Gem it up. Anyone care?


Copyright © 2009 Blake Carlson. See LICENSE for details.

Something went wrong with that request. Please try again.