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

Difference between GridFs and GridFile

As i read on the "gridfs.h" file A GridFS represents a single collection of GridFS files in the database. A GridFile is a single GridFS file. For Example: I have six files...so as per my understanding i can store them in one single GridFS with 6…
Saad Saadi
  • 1,031
  • 10
  • 26
0
votes
1 answer

Spring adding multiple GridFS templates in servlet-context.xml

I am new bie to Spring framework. I am planning use to use two gridfs templates for my next project. I want to use two different databases "ProductImage" and "ProfileImage". Depending on image uploaded by user image should be inserted in relevant…
Sumit D
  • 401
  • 4
  • 15
0
votes
1 answer

MongoDB GridFS image not loaded correctly

I am trying to save images to a MondoDB Collection using GridFS. To test this, I made the following:
tpei
  • 671
  • 9
  • 26
0
votes
1 answer

Can you use find queries on GridFS using javascript API?

As I understand it, when you enter something into GridFS it gets entered into 2 different collections under the hood. One for the raw chunks of data and one for the meta data files. Also from what I understand from MongoDB's documentation is that…
Josh Elias
  • 3,250
  • 7
  • 42
  • 73
0
votes
0 answers

Node.js gridfs-stream download file CPU usage

i have a problem with high cpu usage when streaming file from Mongodb Gridfs to file system. I'm currently using gridfs-stream node.js module and the code is as follows: //Main server file app.get('/download/:name', crud.download) //crud.js…
Case09
  • 313
  • 6
  • 18
0
votes
1 answer

Same image appearing on render but not in source with gridfs-stream (mongoose & mongo driver)

I'm having a strange issue wherein images are being shown more than once on the index, but shows the correct series of images per post in the permalink view. I'm using this controller, routed to /grid/:id exports.getById = function(req, res){ id =…
yolk
  • 729
  • 7
  • 10
0
votes
0 answers

Mapping blob data in spring data mongodb

After reading of manual, it's easy to upload file in GridFS filesystem of MongoDB, but the thing which is missing there is what is proper method to map that file to particular entity? Let's say we have User entity and user's avatar which is…
Yuri Dolzhenko
  • 242
  • 2
  • 7
0
votes
1 answer

Rename a GridFS collection & now cannot see files with the list command in mongofiles utility

Would any one know how I can view in the mongofiles utility the files in my renamed GridFS collection in MongoDB? Frist, I insert a number of text files into the fs collection. When I run: ~$ mongofiles -db mydb list I see the names of the files…
0
votes
1 answer

GridFS.Upload() does not upload stream content

Following example code: using (var ms = new MemoryStream()) { var artifactContent = Encoding.UTF8.GetBytes("content of some file/upload/etc as string"); ms.Write(artifactContent, 0, artifactContent.Length); // ms.Lenght > 0 var…
dna
  • 1,498
  • 1
  • 14
  • 35
0
votes
1 answer

C/C++ Example for GridFS implementation in MongoDB

Just Started building an application on mongodb for file saving and retrieving and found that it has a standard specification for this purpose named as GridFS . But unfortunately i am unable to find any start up example for this in C/C++. If anyone…
Saad Saadi
  • 1,031
  • 10
  • 26
0
votes
0 answers

Serving docx files from MongoDB in PHP

I am having trouble getting .docx files to be served properly from MongoDB. I have this as the code:
0
votes
1 answer

Retrieving an External image and storing in CollectionFS

Alright, so I have an image at a specific URL with the variable path, I want to download it and store it in CollectionFS. How can I get/create the image buffer from the response? var request = Npm.require('request').defaults({encoding:…
puttputt
  • 1,259
  • 2
  • 14
  • 25
0
votes
0 answers

Can not retrieve file from gridFs using the java driver (but can using python)

NOTE; we've completely rewritten the backend in python now, so even though it would still be nice to know what we did wrong, it's not that big of a thing anymore. I've got a known file in my database that has the following objectID…
Lanting
  • 3,060
  • 12
  • 28
0
votes
3 answers

Deleting a file from GridFS

I'm reading GridFS's docs and I'm not sure I'm understanding it. It says right here https://github.com/mongodb/node-mongodb-native/blob/1.4/examples/gridfs.js#L75 that I should delete a file using it's name. But that's just both insane and stupid.…
alexandernst
  • 14,352
  • 22
  • 97
  • 197
0
votes
1 answer

Find the latest version of a document stored in MongoDB - GridFs

I'm planning to use MongoDB GridFs to store different types of flat files, scripts etc. One of the benefits using GridFs is that it creates new document on every insert and thus can be used for versioning purposes using custom meta data etc.…
codehammer
  • 876
  • 2
  • 10
  • 27