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
2 answers

File Upload in MEAN Stack with GridFS: Getting Errors

Cheers mates! I´m trying to make a file upload in my MEAN Application with GridFS. I´m using this tutorial http://www.codetutorial.io/file-upload-gridfs-mean-stack-meanjs/ . After implementing it and checking it ten times, I still get this error:…
David Nnamremmiz
  • 191
  • 1
  • 2
  • 13
0
votes
1 answer

Are indexes deleted after deleting file in GridFS?

I am using GridFS MongoDB via JAVA Driver 2.13. I inserted a file: File file = new File("/home/dev/abc.pdf"); GridFSInputFile inputFile = gfs.createFile(file); I removed it using its _id which is p_id in this case: DBObject query = new…
Dev
  • 13,492
  • 19
  • 81
  • 174
0
votes
2 answers

mongodb gridfs in C# new api

i am new with MongoDB, and i can't find GridFS. Where can i get GridFS to store files now ? I can get it this way: mongoClient = new MongoClient(Settings.Default.MongoDB); var server = mongoClient.GetServer(); MongoDatabase =…
0
votes
1 answer

How to get data as byte[] using GridFS Java API?

I am using Java-driver 2.13. GridFS takes input as File, InputStream or byte[] in createFile() method on GridFS instance to create GridFSInputFile . But when I tried to fetch data back I do have option only as File or outputStream using…
Dev
  • 13,492
  • 19
  • 81
  • 174
0
votes
1 answer

How to change bucket name in MongoDB GridFS?

I am using Mongo-Java-Driver 3.0. How can i change bucket name from fs to new_name in MongoDB GridFS?
Dev
  • 13,492
  • 19
  • 81
  • 174
0
votes
1 answer

insert video(bytes) sent from device in gridfs in mongodb node.js

I am new to gridfs mongodb and creating a POST service to recieve the bytes(of video) and want to save the bytes in mongodb. I have studied gridfs, but couldn't got the clear picture. I have written the code, but I don't know if it is good enough to…
JN_newbie
  • 5,492
  • 14
  • 59
  • 97
0
votes
0 answers

How to use GridFS to store video(binary data) sent from a device and retrieve binary data using mongodb and node.js

I am in learning phase and I need an information, can anyone provide me an example to store video(binary data) sent from a mobile device and retrieve binary data using mongodb Gridfs and node.js. what will be the model and the datatype should I use…
JN_newbie
  • 5,492
  • 14
  • 59
  • 97
0
votes
1 answer

Prettify MongoDb ObjectId

We are developing photo gallery which is storing huge amount of photos. We have choosed MongoDB's GridFS for image storage. Every thing looks fine. But every time when user has to delete the photo we thought of deleting particular photo based on…
sravis
  • 3,562
  • 6
  • 36
  • 73
0
votes
0 answers

Cannot create a new GridStore

I am using Gridfs to create a file and save it in mongodb. I am using console.log to figure out where the error might be. My web app allows users to create a text file and the web app will save it in mongodb. In order to save the file I am using…
0
votes
1 answer

nginx-gridfs: control which documents in a collection can be served via nginx vs my app?

I'm doing some planning for replacing an existing solution with mongodb and potentially using the GridFS functionality for static assets. One question that I have is if I choose to front GridFS with nginx, is there a way to control which assets in a…
RutledgePaulV
  • 2,568
  • 3
  • 24
  • 47
0
votes
1 answer

Mongodb GridFs with C++

I want to insert BSON object from C++ to mongodb gridfs. I cannot find useful doc. about c++ gridfs API. Can you give an example how to insert or update BSON object on gridfs structure in c++. Suppose that i have a collection given below; { "_id" :…
0
votes
1 answer

Creating file in GridFs (MongoDb)

I have two collections, LogData and OptData. LogData is having just 600 records whereas OptData is having around 3 million records. To make some logical data, I am trying to merge both colletions. But merging simply by using mongo command create a…
sangita
  • 191
  • 5
  • 14
0
votes
1 answer

Traverse and Import into GridFS/MongoDB

I am looking to integrate two programs that I have written. The first is an I/O stream that traverses through a directory and lists all of the files within each folder. The second uses the Java driver for MongoDB and allows the input of a file (in…
jmpman
  • 23
  • 1
  • 13
0
votes
2 answers

Import into MongoDB/GridFS

I am new to NoSQL and I am working on developing a parts&supplies database within the Grails framework using MongoDB as the supporting database. I am trying to do an automated initial bulk import of projects and I am looking for some ideas as to…
jmpman
  • 23
  • 1
  • 13
0
votes
0 answers

Idempotent GridFS file store?

I am looking into a possible solution to quite basic question: is there a recommended practice to make sure a file being stored in GridFS is in fact not going to create a duplicate? We noticed that in very rare occasions it might happen that our…
Milan Aleksić
  • 1,415
  • 15
  • 33