Questions tagged [gridfs]

GridFS is a specification for storing large files in MongoDB. All of the mongodb.com supported drivers implement the GridFS spec.

GridFS is a specification for storing large files in MongoDB. MongoDB supports storing binary data directly within BSON documents, however the size is limited by the database's maximum document size (16MB as of the 1.8 production version of MongoDB; 4MB in older versions).

GridFS works by splitting large files into small "chunks", usually 256k in size.

GridFS uses two collections to store data:

  • chunks contains the binary segments of files
  • files contains metadata including the filename, content type, md5 checksum, and any optional information added by the developer

Each file saved in GridFS will have one document in the files collection and one or more documents in the chunks collection.

The GridFS collections also use a prefix (aka namespace). The default prefix is fs, so the default collection names are fs.chunks and fs.files.

GridFS collections are stored in normal MongoDB databases, and can be scaled with standard features such as replication and sharding.

Working with GridFS

All of the mongodb.org supported drivers implement the GridFS spec.

The command-line utility mongofiles can also be used to save, retrieve, list, search, and remove files in GridFS.

Related Links

1101 questions
0
votes
0 answers

How to Query GridFS for particular text in MongoDB

For e.g , I have text file stored in GridFS & I want to check for Text 'Germany' in File for its presence Any idea?
0
votes
1 answer

Is it possible to use GridFS with Ruby Volt?

I want to store some pictures in the database and was thinking about using GridFS to do it efficiently. Is it possible to use GridFS in the Ruby Volt framework? If so, how does one go about doing it?
user3579220
  • 187
  • 1
  • 2
  • 9
0
votes
1 answer

How to serve files from gridfs using nginx (mongo 3.0)?

Is there any alternative to nginx-gridfs that can work with mongodb 3.0 with speed comparable to serving static files using only nginx?
Lisio
  • 1,571
  • 2
  • 15
  • 22
0
votes
1 answer

Read an uploaded file line-by-line (FS.File, stored using cfs:gridfs)

I have a Meteor app where I'd like to upload a text file then have the file parsed on the server. I'm using cfs:gridfs (with cfs:standard-package, of course) to store the files on the server. Client code: Template.uploadPathway.events({ "submit…
Mokolodi1
  • 119
  • 1
  • 10
0
votes
1 answer

Initializing Gridfs returns TypeError: string is not a function

I'm trying to write an uploaded file (such as an image) to a mongodb database. However when I try to initialize the gridfs-stream I get a Type Error. Here's my code: var mongo = require('mongodb'); router.post('/createpost', cpUpload,…
prcbass
  • 339
  • 1
  • 3
  • 17
0
votes
1 answer

Trying to use fs.get function to get the chunks in mongoDB

I am trying to get the files that are stored in mongoDB with GridFS. I wrote this function to store the files into mongoDB using GridFS def write_file_object(file_name): with open(file_name) as mydoc: b = fs.put(mydoc,…
Qing Yong
  • 127
  • 3
  • 15
0
votes
1 answer

chrome and safari don't render images in html template served by a go server with Content-Length is set

I stored some images on GridFS and served the resource with a simple Go web server. func GetFile(w http.ResponseWriter, r *http.Request) { fileObjectId := r.URL.Path[len("/file/"):] gfs := db.GridFS("fs") file, err :=…
0
votes
1 answer

Download of GridFs using nodejs does not start

I'm trying to download a binary file of +200M saved in a mongoDB using the GridFS. My problem is that the download won't start. I'm using nodejs with mongodb and gridfs-stream. In routes.js: router.get('/getlog',function(req,res) { if…
cauchi
  • 1,463
  • 2
  • 17
  • 45
0
votes
2 answers

Matching result of MongoController.serve

MongoController provides serve function to serve the result of a query (as a Cursor). I just want to do something different than letting serve return NotFound, like sending some other default file. I'm wondering if it is possible to use pattern…
0
votes
1 answer

Confusion in by default chunk size in GridFS

MongoDB manual says by default chunk size is 255K. Its current Java API says its 256K. Which one is right or both?
Dev
  • 13,492
  • 19
  • 81
  • 174
0
votes
1 answer

Distributed file system for linux

I've got a web app where I use plain file system for my custom logs - a lot of small files, I don't want to put that into db, that works for me quite well. But now I need to scale my app by using a load balancer in front, so I also need to keep…
Kubber
  • 367
  • 3
  • 13
0
votes
0 answers

read video file from mongodb with pymongo

I have a large video file stored in MongoDB gridFS. I would like to read it and write it on my disk. I can find the file in the database with: file = grid_fs.find_one({"filename":'file_in_database.cin'}) I get back a grid out object…
0
votes
1 answer

Spring MVC (and angularjs) - Retrieving images: high memory usage in Chrome

I have stored images in my database and need to serve these images to the user on his webbrowser. My problem is that the following method, which serves these images, is causing my webbrowser to consume a lot of memory (600 MB). The reason I know…
Moody
  • 851
  • 2
  • 9
  • 23
0
votes
2 answers

GET images from GridFs to Angular

I´m storing images from my angular app in MongoDB using GridFs. But i cant figure out, how to GET the images out of the DB to the app? I´m using a custom objectId for the query. EDIT It looks like the GET part now works, but then there was no media…
Wandkleister
  • 189
  • 1
  • 3
  • 13
0
votes
1 answer

Serve files in img src using HTTP.get

My file can only be served if I add an x-authentication token to the header of the "GET" http request (and I don't want to use a cookie). The direct consequence is that I can not call for a file just by using its URL in the html, I need to get it…