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
87
votes
5 answers

Is GridFS fast and reliable enough for production?

I develop a new website and I want to use GridFS as storage for all user uploads, because it offers a lot of advantages compared to a normal filesystem storage. Benchmarks with GridFS served by nginx indicate, that it's not as fast as a normal…
Railsmechanic
  • 1,045
  • 1
  • 9
  • 13
77
votes
9 answers

HTML5 video will not loop

I have a video as a background to a web page, and I am trying to get it to loop. Here is the code:
68
votes
3 answers

MongoDB GridFs with C#, how to store files such as images?

I'm developing a web app with mongodb as my back-end. I'd like to have users upload pictures to their profiles like a linked-in profile pic. I'm using an aspx page with MVC2 and I read that GridFs library is used to store large file types as…
EKet
  • 7,272
  • 15
  • 52
  • 72
42
votes
4 answers

Distributed File Systems: GridFS vs. GlusterFS vs Ceph vs HekaFS Benchmarks

I am currently searching for a good distributed file system. It should: be open-source be horizontally scalable (replication and sharding) have no single point of failure have a relatively small footprint Here are the four most promising…
Alp
  • 29,274
  • 27
  • 120
  • 198
38
votes
2 answers

Meteor: uploading file from client to Mongo collection vs file system vs GridFS

Meteor is great but it lacks native supports for traditional file uploading. There are several options to handle file uploading: From the client, data can be sent using: Meteor.call('saveFile',data) or collection.insert({file:data}) 'POST' form or…
Green
  • 4,950
  • 3
  • 27
  • 34
31
votes
5 answers

How to use GridFS to store images using Node.js and Mongoose

I am new to Node.js. Can anyone provide me an example of how to use GridFS for storing and retrieving binary data, such as images, using Node.js and Mongoose? Do I need to directly access GridFS?
Dar Hamid
  • 1,949
  • 4
  • 21
  • 27
31
votes
2 answers

Storing some small (under 1MB) files with MongoDB in NodeJS WITHOUT GridFS

I run a website that runs on a backend of nodeJS + mongoDB. Right now, I'm implementing a system to store some icons (small image files) that will need to be in the database. From my understanding, it makes more sense NOT to use GridFS, since that…
thisissami
  • 15,445
  • 16
  • 47
  • 74
29
votes
3 answers

MongoDB as file storage

i'm trying to find the best solution to create scalable storage for big files. File size can vary from 1-2 megabytes and up to 500-600 gigabytes. I have found some information about Hadoop and it's HDFS, but it looks a little bit complicated,…
cmd
  • 515
  • 3
  • 9
  • 19
28
votes
1 answer

Django with Pluggable MongoDB Storage troubles

I'm trying to use django, and mongoengine to provide the storage backend only with GridFS. I still have a MySQL database. I'm running into a strange (to me) error when I'm deleting from the django admin and am wondering if I am doing something…
Aaron
  • 4,206
  • 3
  • 24
  • 28
20
votes
3 answers

Sharding GridFS on MongoDB

I'm documenting about the GridFS and the possibility to shard it among different machines. Reading the documentation here, the suggested shard key is chunks.files_id. This key will be linked to the _id of the files collection, thus this _id is…
ALoR
  • 4,904
  • 2
  • 23
  • 25
19
votes
1 answer

MongoDB GridFS VS Directly disk IO

Use MongoDB GridFS store images and images stored directly on disk What are the advantages?
19
votes
4 answers

How to chain write stream, immediately with a read stream in Node.js 0.10?

The following line will download an image file from a specified url variable: var filename = path.join(__dirname, url.replace(/^.*[\\\/]/, '')); request(url).pipe(fs.createWriteStream(filename)); And these lines will take that image and save to…
Sahat Yalkabov
  • 32,654
  • 43
  • 110
  • 175
18
votes
5 answers

Storing data stream from POST request in GridFS, express, mongoDB, node.js

I am trying to figure out how I can post an image directly to GridFS without storing it anywhere on the server as a temporary file first. I am using Postman (chrome ext.) to post a file, and I manage to store this post as a file using:…
eirik
  • 407
  • 1
  • 4
  • 9
17
votes
2 answers

Spring Data + MongoDB GridFS access via Repository possible?

I recently discovered GridFS which I'd like to use for file storage with metadata. I just wondered if it's possible to use a MongoRepository to query GridFS? If yes, can someone give me an example? I'd also take a solution using Hibernate, if there…
Benjamin M
  • 23,599
  • 32
  • 121
  • 201
15
votes
2 answers

Do any open-source standalone restful image servers exist?

I'm planning to develop a standalone restful Image Server with the following functionality, but first would like to know if something similar already exists in the open source world (language not important): restful (crud) on master image, e.g:…
Geert-Jan
  • 18,623
  • 16
  • 75
  • 137
1
2 3
73 74