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
1 answer

How can I do a replace with gridfs-stream?

I'm using this code to do a file update: app.post("/UploadFile", function(request, response) { var file = request.files.UploadedFile; var name = request.param("Name"); var componentId = request.param("ComponentId"); …
Mike Pateras
  • 14,715
  • 30
  • 97
  • 137
0
votes
1 answer

Serving files from GridFS with casbah/salat

I would like to store images uploaded as user content in GridFS in a Scala Play 2 application. How can I restore the binary file from the GridFSDBFile that GridFS.findOne gives me?
laci37
  • 510
  • 4
  • 17
0
votes
1 answer

Lithium PHP GridFS image read failures

In trying to fetch images from a MongoDB GridFS collection using the 1.3.4 driver and the Lithium PHP framework, I'm getting broken images. I am having trouble pinpointing when this started happening, as, although the site in question is not live…
0
votes
1 answer

Binding to MongoDB service from Grails application deployed on Cloudfoundry

I'm currently writing a Grails app using Grails 2.2.2 and MySQL, and have been deploying it to Cloudfoundry. Until recently I've just used a single MySQL datasource for my domain, which Cloudfoundry detects and automagically creates and binds a…
rcgeorge23
  • 3,594
  • 4
  • 29
  • 54
0
votes
1 answer

How can I manage the disk size of a GridFS MongoDB database?

I have a GridFS MongoDB database that I need to manage the size of. It has been running very well since it was created, but I have never really looked at its disk size until now. Judging by this outout from the db.stats() command > db.stats() { …
c00kiemonster
  • 22,241
  • 34
  • 95
  • 133
0
votes
2 answers

Storing posted file to MongoDB GridFS, using ExpressJS and Node

I'm attempting to process file posted to an Express site by placing it into MongoDB's gridfs system, using the native driver. The problem I'm experiencing is that the request's chunks have all been sent before the gridStore object is even ready. …
OmegaX
  • 91
  • 1
  • 7
0
votes
1 answer

GridFS: Cursor positioning works only one time after "seek"

I am positioning the cursor within a file with GridStore.seek (GridStore.IO_SEEK_CUR) but it works only one time. With the next read and all forthcoming read's and seek's the cursor is not positioned any more. If I omit the seek all read's move the…
heinob
  • 19,127
  • 5
  • 41
  • 61
0
votes
1 answer

Querying mongodb gridfs file data

hi i am a newbie to gridfs and am able to insert a file and view the file in gridfs using the query below mongofiles -d myfiles put hi.txt db.fs.files.findOne({'filename':'hi.txt'}); I need to view the contents of the file(hi.txt) i tried…
Amanda G
  • 1,931
  • 10
  • 33
  • 43
0
votes
2 answers

Is MongoDB's GridFS Chunking Just for Binary Data? What about Huge K/V Documents?

I have documents that exceed 16MB. These documents are comprised of many key/value pairs and their containing subdocuments (dicts) and arrays (lists), which may be nested several levels deep. If I try to insert one of these super-16MB files, I get…
SYNAX
  • 75
  • 4
0
votes
1 answer

MapReduce on gridfs file with mongodb

I want to store bson documents in gridfs because they grow rapidly over 16MB. But i also have to do some mapreduce analytics on them. Is that possible or do i have to split the document in multiple documents to do that. Tutorials and other stuff…
Finn
  • 198
  • 9
0
votes
1 answer

GridFS file retrieval strategy

I have been looking at GridFS to store images and other files. It has some really nice features but we have to retrieve and store files at some temporary location to render html which costs us cpu time. What would be a good strategy to use GridFS…
Udayan
  • 45
  • 4
0
votes
2 answers

MongoDB GridFS driver in NodeJS overwrites files with the same name

I have the following code (removed error checking to keep it concise) which uses the node-mongodb-native. var mongo = require('mongodb').MongoClient; var grid = require('mongodb').GridStore; var url =…
BytesGuy
  • 4,097
  • 6
  • 36
  • 55
0
votes
1 answer

How to move file from GridStore (GridFS) to File System for download?

I have some files in GridFS and I want to download them to the browser. It is my understanding that I need to take the file from GridFS and move it to the server's file system in order to send it to the browser. Can someone point me in the right…
user810606
0
votes
1 answer

Delete file on mongoDb gridFs results in "0", even if it is there

is there anything obvious I'm doing wrong with this code? $result = $this->_grid->remove( $someQueryWithOneResult, array('safe' => true, 'justOne' => true) ); if ($result['n'] === 0) { throw new FileNotFoundException("no file with xuuid '" .…
Marko
  • 514
  • 1
  • 4
  • 16
0
votes
1 answer

Store Stream in GridFS using Node.js

I'd like to store a Stream in a GridFS. However it doesn't work as expected (i.e. no console log). var mongo = require("mongodb"); var db = ... db.open(function (err, db) { var stream = ... var name = 'foobar'; var gs = new…
SecStone
  • 1,733
  • 4
  • 20
  • 31