Skip to content
This repository has been archived by the owner on Nov 29, 2022. It is now read-only.

vvlad/node-gridfs-http-frontend

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

27 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

node-gridfs-http-frontend

HTTP frontend to serve files from MongoDB's GridFS using nodejs

Running

$ gridfs-http-frontend
$ gridfs-http-frontend --backend=mongodb://my-gridfs.local:27117/gridfs --listen_address=0.0.0.0 --listen_port=3000
$ gridfs-http-frontend --config=path_to_config.js

There's also an example Upstart script in the 'upstart' directory

Config

Defaults

  • backend = mongodb://127.0.0.1:27017/gridfs
  • listen_address = 127.0.0.1
  • listen_port = 3000

Order of config variable resolution

  1. --config=[configfile.js]
  2. [executable]/lib/config.js
  3. command line args: --backend=mongodb://my-gridfs.local:27117/gridfs --listen_address=127.0.0.1 --listen_port=300

Command line args will override any coming from a config file.

Example config.js
  exports = module.exports = {
    listen: {
      address: process.env.HOSTNAME,
      port: process.env.PORT || 3000,
    },
    backend: process.env.DATABASE_URL || "mongodb://127.0.0.1/test",
  };

Requesting files from the Server

GridFS files will then be available at http://gridfs-http.local:3000/[grid_id]

Optionally - file URLs can have appended a forward slash and (anything else) e.g. http://gridfs-http.local:3000/[grid_id]/my_nice_filename.jpg

Note this differs from the upstream, which serves files based on filename.

GridFS Tool

$ gridfs ls
Sat Oct 26 2013 21:18:24 GMT+0300 (EEST)  6bb7c31d7ca6538aafa571b62b17118f  package.json
$ gridfs cat package.json
{ ... }
$  gridfs put package.json
Done
$ gridfs
start:  starts the a web server
ls: list the files that are maching the given pattern
cat:  print a file content
rm: removes a file
put:  uploads a file into the grid
help: displays help for a given command

About

A http forntend for serving files form MongoDB's GridFS

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published