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

using GridFS with Tornado templates

i've a problem when making a loop using a GridFS pictures: class VentesHandler(BaseHandler): @tornado.web.authenticated def get(self): user = self.get_secure_cookie("mechtari") info = tornado.escape.json_decode(user) …
Abdelouahab Pp
  • 4,252
  • 11
  • 42
  • 65
0
votes
1 answer

GridFS issues with a Mongo Import

I have a production server running Mongo 2.0.7 and a local machine that runs Mongo 2.0.6. I exported a database as a JS file and then imported it in my local machine. EVerything seems to be working fine however I am unable to server GridFS files.…
Strong Like Bull
  • 11,155
  • 36
  • 98
  • 169
0
votes
2 answers

How to store files of different types in separate collections using Lithium and GridFS?

I have a model that looks like this: class Pdf extends \lithium\data\Model { protected $_meta = array('source' => 'fs.files'); protected $_schema = array('_id'=>array('type'=>'id')); public $file; /** * @param $zipfile string…
Terrence
  • 1,032
  • 1
  • 8
  • 16
0
votes
1 answer

Reading file contents with casbah gridfs throws MalformedInputException

Consider the following sample code: it writes a file to mongodb and then tries to reread it import com.mongodb.casbah.Imports._ import com.mongodb.casbah.gridfs.Imports._ object TestGridFS{ def main(args: Array[String]){ val mongoConn…
Jean
  • 21,329
  • 5
  • 46
  • 64
0
votes
1 answer

Sort by uploadDate on GridFS in Java

GridFS store filename and uploadDate by default. MongoDB Java driver allow you to find by String Id and DBObject query. How would I find a file by filename, sorted by uploadDate?
ltfishie
  • 2,917
  • 6
  • 41
  • 68
0
votes
0 answers

Unable to display images in browser using GridFS

So I think I have done everything in order to server images and am unable to see an image even though I have followed the instructions precisely on this site: http://jwage.com/2010/07/27/storing-files-with-mongodb-gridfs/ When I do: $dm =…
Strong Like Bull
  • 11,155
  • 36
  • 98
  • 169
0
votes
1 answer

GridFS does not play well with AfNetworking or remote downloading of images

I have an app that used GridFS to store the images of a document (references). I am trying to use AfNetworking to download the images when a UITableViewCell is shown. However AFNetworking does not have a method that deals with image data that is…
Strong Like Bull
  • 11,155
  • 36
  • 98
  • 169
0
votes
2 answers

Config CarrierWave with Mongoid - GridFS

I am getting a trouble, trying to use CarrierWave for a file upload Rest API developed in Rails 3, with a MongoDB database. What I would like to do is storing some files (not only images but every file format) with the MongoDB system GridFS. I read…
Flo Schild
  • 5,104
  • 4
  • 40
  • 55
0
votes
2 answers

can't get pictures from gridFS using Tornado

my problem is that i can get the save picture to gridFS even if it's there, i've verified and it show me the piture and its name and the size from the console. here is the code: conn = Connection() the classe that saves to the database: class…
Abdelouahab Pp
  • 4,252
  • 11
  • 42
  • 65
0
votes
1 answer

mongoDB pinboard schema

I am creating pinboard (something like http://www.pinterest.com). I am using MongoDB as database (to store all pins). Pins { userid, img, title, description, comments { [userid, username, comment] } } I want to store…
Tomas
  • 333
  • 1
  • 15
0
votes
1 answer

How do I set the prefix/collection that GridFS uses with the node-mongodb-native driver?

The mongo API allows for you to set what prefix the GridFS system uses. By default this is "fs", so you'll end up with the collections fs.files and fs.chunks. I'd like to have several different collections of files, so I need to be able to specify a…
thisissami
  • 15,445
  • 16
  • 47
  • 74
0
votes
1 answer

Error on large files with GridFS and MongoDB

I seem to be getting an error when trying to upload large files into MongoDB.. Fatal error: Uncaught exception 'MongoGridFSException' with message 'could not open file ' in /home/jclark/thundergrid.fusionstrike.com/thundergrid/thundergrid.php:33…
user1400312
0
votes
2 answers

nodejs gridfs grid.put() with identical filename overwrites file

When I am writing a file into GridFS using grid.put(), which has the same filename as a file stored before, the first file is going to be overwritten. Is it actually true that the same filename can only exist once in the database or am I doing…
heinob
  • 19,127
  • 5
  • 41
  • 61
0
votes
1 answer

nodejs gridfs buffer is offset by two bytes

I'm using this function to retrieve the file. there are some other function calls before that pulls the md5sum out of the request, makes sure the file exists, then calls buildFile(). FileChunker.prototype.buildFile = function(file, callback) { …
neoice
  • 2,233
  • 3
  • 19
  • 15
0
votes
2 answers

How to use const char pointer returned from a function in this instance? (mongodb related)

I'm having a bit of trouble with a a function that the mongodb c driver uses. The function in question looks like this: gridfile_get_field (gridfile *gfile, const char *name) (returns const char *) I'm attempting to use it in the following…
the_man_slim
  • 1,155
  • 2
  • 11
  • 18