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

mongodb c# driver with GridFS and .Net garbage collection

I evaluated GridFS APIs using MongoDB C# driver for storing files. I understand it expose streams to read and write. Just want to check if anyone encountered .Net GC issues in real life (specifically around Gen2). I don't know the driver's…
frosty
  • 2,421
  • 6
  • 26
  • 47
0
votes
1 answer

Get GridFS files within ids with PHP

I am using MongoDB GridFS to store some user avatars. My backend is PHP. On some page I need to display all images with single user. So I have the Mongo IDs. How do I perform a find query where _id is in given IDs. In mongo the query would be {"_id:…
ArVan
  • 4,225
  • 8
  • 36
  • 58
0
votes
3 answers

Storage overhead of GridFS

We have a MongoDB Cluster using GridFS. The fs.chunks table of gridfs is sharded over two replicasets. The usage of diskspace is very high. For 90GB of data we need more than 130GB of diskspace. It seems like the fs.chunks table is needing the…
Marko
  • 514
  • 1
  • 4
  • 16
0
votes
1 answer

How to download files stored in monogdb with gridfs using spring mvs

I have saved a file into mongoDB using gridFS like so. Mongo mongo = new Mongo("XXXXX", XXXX); DB db = mongo.getDB("XXX"); GridFS fs = new GridFS(XXX); File install = new File("C:\\Users\\Nabeel\\Desktop\\docs.txt"); …
Nabeel
  • 15
  • 1
  • 12
0
votes
1 answer

how can I get a file, saved using gridform?

I'm using gridform to save a file in gridfs, how can I get the file to return it to a user?
jperelli
  • 6,988
  • 5
  • 50
  • 85
0
votes
0 answers

How should I design my data storage scheme using mongoDB?

My data is like belows : I have about 1,000,000 gene sequence data ,but some of them are very short ,hundreds of characters , but some of them is so large that its BSON size has already exceeds the 16M per-document size limit of MongoDB ,up to…
wuchang
  • 3,003
  • 8
  • 42
  • 66
0
votes
1 answer

How to create GridFS collection?

I have read a number of documents till now on MongoDB and am interested in creating a GridFS collection to store files. I already have created the PHP script which can deal with files stored in MySQL (blob datatype) and it is working. However I now…
Vaibhav Kaushal
  • 340
  • 1
  • 6
  • 16
0
votes
1 answer

How should I understand mongoDB GridFS?

I am now using perl script client to store some big data into mongoDB .But now I met a problem ,some document exceeds the size limit of 16M,so ,I have to choose GridFS.From the GridFS document ,I read this: GridFS is a specification for storing and…
wuchang
  • 3,003
  • 8
  • 42
  • 66
0
votes
1 answer

Carrierwave dynamic storage type via model attributes

I want to save photographs in 'grid_fs' and other types of files into 'fog', like: class DocumentUploader < CarrierWave::Uploader::Base def storage if model.is_photograph == true :grid_fs else :fog end end end Is this…
0
votes
1 answer

Nginx write files into GridFS

We have the module "nginx-gridfs" (https://github.com/mdirolf/nginx-gridfs) to serve contents OUT of GridFS, but are there any modules that can allow Nginx to accept upload files and write them into GridFS? The Nginx upload module only supports…
MK Yung
  • 4,344
  • 6
  • 30
  • 35
0
votes
1 answer

MongoDB - search GridFS file contents by string

I am planning to upload user's word documents in MongoDB using GridFS. I have to implement following functionality. When admin type a string and hit search in administration app, i have to list all word documents where the contents contain the…
user10
  • 5,186
  • 8
  • 43
  • 64
0
votes
1 answer

Performance in MongoDB and GridFS

I am developing a plugin that using mongodb. The plugin has to store some .dcm files (DICOM files) in the database as binary files. After that, the plugin has to store the metadata of the file and be able to make some query on only these…
loulou8284
  • 15
  • 1
  • 8
0
votes
1 answer

mongodb gridfs encoding picture base64

i try to readout an image, saved in mongodb, via gridfs (without temporary file) it should be directly sent to ajax, which injects it into html when i use my actual functions a large bit string is formed and sent to client (is saved in ajax response…
Pika
  • 154
  • 11
0
votes
1 answer

Haskell mongodb gridfs

Is there support for gridfs in haskell driver? If not, would it be OK to store binary files without gridfs if they are under 16M? All I need is to store some attachments like .txt .doc .xls .pdf .jpg Thanks.
r.sendecky
  • 9,933
  • 9
  • 34
  • 62
0
votes
1 answer

Mongoengine delete file gridfs

I am using mongoengine to insert images in mongodb's GridFS. Insert everything is ok, but I now want to delete, and I'm not getting. I am using version 0.8.2 and I'm mongoengine to do so: class Animal(Document): genus = StringField() …
Helio
  • 81
  • 4