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

How to save via mongodb shell a file served by GridFS in a mongoengine/Django FileField

I have a file saved on GridFS, via mongofiles $ mongofiles -d dba put file.txt connected to: 127.0.0.1 added file: { _id: ObjectId('50c0a48f8d1d53325a7d7b01'), filename: "file.txt", chunkSize: 262144, uploadDate: new Date(1354802319244), md5:…
gc5
  • 9,468
  • 24
  • 90
  • 151
0
votes
1 answer

Show image saved into mongodb gridfs with node.js

I am saving images of my aplication into gridfs. The problem becomes when I need to show the image. I don't know how can i do it. I'm using node.js, geddy framework and mongodb. this.show = function (req, resp, params) { var self = this; var…
pekpon
  • 761
  • 1
  • 10
  • 24
0
votes
1 answer

PHP + GridFS: Own id

I want save many files using MongoDB's GridFS but I ran into some trouble by using my own id. My simplified code is the following: myFiles; $grid =…
Nrgyzer
  • 783
  • 1
  • 14
  • 38
0
votes
1 answer

Not able to download file from MongoDB GridFS as stream with nodejs/expressjs

I am using NodeJs 1.9.x with express 3.x, mongoose 3.3.x and gridfs-stream modules. Following is upload code. Which is working great. var mongoose = require('mongoose'); var fs = require('fs'); var GridStrm =…
Jak
  • 2,893
  • 3
  • 19
  • 33
0
votes
1 answer

how do i use gridfs with libraries that dont accept non-blocking gridfs?

how do i use gridfs with libraries that dont accept non-blocking gridfs and only non-blocking other calls? i got error: from mongotor.database import Database import gridfs db = Database.connect("localhost:27017", "mydb") fs =…
Abdelouahab Pp
  • 4,252
  • 11
  • 42
  • 65
0
votes
1 answer

In which format to send image via node js to store with gridfs

I have a client written in xcode and I would like to upload the user pic to be stored on the server. The server run node js and I store the uploaded files with gridfs How should I send the picture in nodejs query. Is it suppose to be binary format…
Liatz
  • 4,997
  • 7
  • 28
  • 33
0
votes
1 answer

MongoDB+GridFS on Symfony2

I need to store some files in my Mongo database and came across these two questions: I do not care about the names of these files, I'll be addressing them by their unique mongo id. the Mongo db driver by default adds the filename as it is adding…
Reza S
  • 9,480
  • 3
  • 54
  • 84
0
votes
1 answer

GridFS convert files to IO files

I have a java web application that at some point will render pages with a lot of pictures. Those pictures are of inserted in jsp as html img tags. User can see those in the browser. The quantity of pictures is growing and I am thinking to move them…
Mircea Stanciu
  • 3,675
  • 3
  • 34
  • 37
0
votes
1 answer

Assign WriteConcern to mongo file system

Colleagues, I'm using Mongo of v2.2 and java Mongo driver 2.9.0, Some business logic creates approximately 25 threads and each thread creates 150 files on GridFS. Approximately 20 files per 1000 are not return correct getId() so result is null. I…
Dewfy
  • 23,277
  • 13
  • 73
  • 121
0
votes
1 answer

Save chunks of http.request into grifFS node.js

You can save the data received from a http.request post directly into GridFS to minimize memory usage? Can anyone give me an example, Note: the size of data are 10Mb+, im using Post to send and i can't do this request.addListener('data', function…
manell
  • 1
  • 1
0
votes
1 answer

Scala Lift - Delete file in mongo gridfs

I'm trying to find the correct method of deleting a file from mongodb gridfs. Would the standard query suffice? record.delete_! Or is there a specific way of doing it properly? Thanks in advance, any help much appreciated :)
jahilldev
  • 3,520
  • 4
  • 35
  • 52
0
votes
1 answer

nodejs mongodb Gridstore.exist infinite loop

I am trying to use GridStore of mongodb, I have a wierd infinite loop problem when I try the following code GridStore.exist(db, req.params.filename, function(err, result){ The following is the whole code and its debug output var express =…
kkites
  • 349
  • 1
  • 7
0
votes
1 answer

GridFS elements dont follow Document elements

it seems bizarre, but when deleting and element in a document and try to remove the _id from GridFS (removing a product + its image), it gives me an error, because the picture removed si NOT the element's picture! the id of the picture i've made…
Abdelouahab Pp
  • 4,252
  • 11
  • 42
  • 65
0
votes
1 answer

Is there a version limit in GridFS?

In mongodb GridFS when you insert a file with the same name as an already existing file the old file becomes a previous version of the new file. I'm wondering can I do this multiple times and is there a limit? For example, I have a file file.txt,…
toofarsideways
  • 3,956
  • 2
  • 31
  • 51
0
votes
1 answer

Retrieving an image from mongoengine and display it on a page as http reponse in python

Hello am new with mongoengine. I just want to retrieving an image from mongoengine and display it on a page as http reponse in python. I have added images to database and i printed it in the console and i got the following result:
Pravitha V
  • 3,308
  • 4
  • 33
  • 51