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

GridFS disk management

In my environments I can have DB of 5-10 GB or DB of 10 TB (video recordings). Focusing on the 5-10 GB: if I keep default settings for prealloc an small-files I can actually loose 20-40% of the disk space because of allocations. In my production…
RoeeK
  • 1,112
  • 12
  • 23
0
votes
0 answers

Using nginx file upload when using MongoDB?

Users says that Tornado is bad for file upload since it uses memory, so they use Nginx, but my question, is: What if the files are not stored in the normal system, but in MongoDB (GridFS), then, Nginx will be useless?
Abdelouahab
  • 7,331
  • 11
  • 52
  • 82
0
votes
1 answer

GridFs bug with java driver

I am using Gridfs for storing a big file in mongodb. This is my code to insert the file: GridFS bigFile = new GridFS(db, "35"); File f = new File(path+"/element.son"); GridFSInputFile gfsFile =…
ilamaiolo
  • 345
  • 2
  • 4
  • 14
0
votes
2 answers

WriteConcernException when closing Mongo GridFS file stream

I'm using MongoDB driver in C#, and store video files using GridFS. I store the files continuously like recording a stream and once in a while (might be in middle of writing process) I ask to "play" a file. In some cases, at that part of playing the…
RoeeK
  • 1,112
  • 12
  • 23
0
votes
1 answer

Maximum call stack size exceeded - saving to GridFS - no recursion happening

I'm trying to save a file into GridFS in node.js. The usecase is actually really straight forward: "upload a file to a restify app, save it into GridFS". function put(req, res, next) { var ws, filename; var application = new…
Roman
  • 5,888
  • 26
  • 47
0
votes
1 answer

part of the video from gridfs mongodb in java?

I have uploaded a video file .mp4(18MB) into gridfs . and trying to read it from java code .here are some points i am unable to move further 1) i can able to retrieve the whole video into byte array and able to play 2) for first Nbytes means…
Shiv
  • 1
  • 2
0
votes
1 answer

error ENOENT,open with gridFS and node js

I am trying to save a project and its file using GridFS. I want to save project first and use "_id" of project as metadata for file. Here is my code: newProject.save(function (err,project) { if (err) { console.log('save…
Abhas Tandon
  • 1,859
  • 16
  • 26
0
votes
1 answer

how to upload file and store it in mongodb?

in this example "path" is path to (uploaded)temporary file in server? or file path in client's device? i'm reading files metadata from $_FILES but don't know where to read the file to store in db. please help. (sorry for my english)
Mher Didaryan
  • 95
  • 2
  • 13
0
votes
1 answer

django + mongodb + gridfs - 'str' object has no attribute 'size'

I am attempting to get mongodb + gridfs working for django so that I can serve files out of django, but upon programmatically creating a new file, I get this error. I'm not sure which documents to follow as it appears some of them are out of…
Walter
  • 1,290
  • 2
  • 21
  • 46
0
votes
1 answer

Storing base64 strings to GridFS(mongoDB file storage)

I'm trying to paste an image from the clipboard into an tag. The source of this image is Prnt Scrn command and not a file. This clipboard image would be in base64 format. This base64 string can be inserted into src attribute of tag(once…
Vineeth Pradhan
  • 8,201
  • 7
  • 33
  • 34
0
votes
3 answers

Remove all files from Mongo GridFs (both files and chunks)

I'm writing some tests agains MongoDb GridFs and want to make sure that I start each test with a clean slate. So I want to remove everything, both from fs_files and fs_chunks. What's the easiest way to do that?
Marcus Hammarberg
  • 4,762
  • 1
  • 31
  • 37
0
votes
1 answer

Stream file to MongoDB with PyMongo

I'm trying to upload a large file into GridFS using PyMongo and an API I wrote in Tornado. Since the file size is 4.1GB Tornado throws an Content-Length too long. This scenario works with NodeJS and this module but I am unsure if PyMongo supports…
ivica
  • 1,388
  • 1
  • 22
  • 38
0
votes
1 answer

gridfs-stream createWriteStream not uploading data

I am using following code to create a file in mongodb. I get no error. But when i chech my Test database nothing is seen there uploaded. What am i doing wrong? var GridStrm = require('gridfs-stream'); console.log('Logo Upload'); var conn =…
Anup
  • 9,396
  • 16
  • 74
  • 138
0
votes
1 answer

'end' event from readstream is emitted twice

I'm trying to make file uploading to mongodb's gridfs in nodejs. Here's a piece of my code: var fs = require('fs'); var gridfs = require('gridfs-stream'); var mongo = require('mongodb'); var gfs; mongo.Db.connect('mongodb://...', function (err, db)…
xaxa
  • 1,057
  • 1
  • 24
  • 53
0
votes
1 answer

How to change the chunksize and Retrieve specific chunk in Mongodb Gridfs?

I am pretty much new in Mongodb now what I want to do is to insert a pdf file of 3MB using JAVA driver and want change the chunk size from 256 to 1mb and then want to retrieve the second chunk say 2nd page of the pdf document. How can I do…
user2168912