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

mongoengine how to copy a file

I have a requirement where a user uploads files to the File collection class File(Document): user = ReferenceField(User) file = FileField() type = StringField(choices = ('project', 'uploads')) The user can then submit a file for…
spitz
  • 658
  • 1
  • 8
  • 19
0
votes
1 answer

error getting files from gridfs

I'm trying to display images and files from gridfs. So I started with the save function and it's working well: import javax.inject.Inject import org.joda.time.DateTime import scala.concurrent.Future import play.api.Logger import…
Rajeun
  • 721
  • 2
  • 12
  • 37
0
votes
1 answer

video tag makes call for one byte of data only on mobile (Node.js)

I have created a node server that streams mp4 videos from a Mongo database using gridfs. I have no issue when streaming the video to a desktop browser but when I try to stream to any mobile device I only see the video player but it will not play.…
Connor
  • 1
  • 4
0
votes
1 answer

Downloading multiple files using AngularJS and storing in path

I am new to Angular,I have a scenario, where I need to download multiple files at the same time. My files are stored in GridFS. I am able to download the files, but for example a pdf is blank. The contentType stored in gridFS is "contentType":…
Rahul Ganguly
  • 1,908
  • 5
  • 24
  • 36
0
votes
1 answer

Store filename and objectid tuple in collection or query direct using the filename

Currently I'm struggeling with querying data from a MongoDB GridFS by using the filename. Current situation I'm uploading data to the MongoDB by using a GridFSBucket and UploadFromBytesAsync which returns an ObjectId for referencing the data and…
BendEg
  • 20,098
  • 17
  • 57
  • 131
0
votes
0 answers

File stream parsing with busboy and write directly into GridFs in express

:) Hi! I'm trying to figure out how to write uploading file directly into GridFs in express framework. I wrote codes as below and the problem is that file event "file" is never emitted. :( var mongoose = require('mongoose'); var express =…
Woonggeun Jang
  • 227
  • 1
  • 2
  • 10
0
votes
0 answers

Generic way to display any file from GridFS

Given a file from GridFS, I'd like to be able to display it on a webpage. The files in my database can be of any common type, including jpgs, pngs, xml, txt, csv, etc. A user would like to be able to click on the name of the file and in a new tab…
Village
  • 199
  • 3
  • 15
0
votes
0 answers

MEAN : Serve File from GridFs

I am using MEAN stack and I am trying to serve a file stored using Mongo GridFs. This is the code I have tried so far. exports.getFile = function(req, res) { var fileId = req.params.fileId; gfs.findOne({ _id: fileId }, function (err, file) { …
vinesh
  • 4,745
  • 6
  • 41
  • 45
0
votes
0 answers

ajax upload image and store in gridfs

the doc of native mongoDB driver about gridfs is just push a local file to gridfs, http://mongodb.github.io/node-mongodb-native/2.1/reference/gridfs/streaming/ how do I get the file submitted by multipart/form-data form of ajax ?
Littlee
  • 3,791
  • 6
  • 29
  • 61
0
votes
2 answers

spring data mongodb 1.8.x - GridFS collection name in XML

is possible modify collection name of gridfs target in configuration XML? Default name is "fs.files" this is a configuration file:
Furetto
  • 329
  • 3
  • 9
0
votes
1 answer

Streaming video file form GridFS using Jersey?

Hey So I have the following code that is used by a client side application to play a video file that is stored in MongoDB(using GridFS). My question here is does the code have to wait until every byte that makes up the video file is written into…
fulhamHead
  • 687
  • 1
  • 10
  • 23
0
votes
0 answers

MongoDb document size is too large PhP.How to increase limit

i want to save documents but it gives me size too large error. I can not break data into multiple collection as it will not help me while searching and joining, Is there a way that i can save array using gridFs and it is still searchable or increase…
Saavan Mehta
  • 83
  • 1
  • 10
0
votes
1 answer

Uploading duplicate file names using grids and mongo

I have an application that uses grids to upload files to mongodb. Its actually a two step process. First, the file is uploaded and upon success the filename is pushed into a collection (js array, not mongo collection) which is bound to the UI with…
Lazloman
  • 1,289
  • 5
  • 25
  • 50
0
votes
0 answers

PHP MongoDB GridFS support

I'm using MongoDB's GridFS for saving files, but i noticed deprecation notice here on http://php.net/manual/en/mongo.installation.php and to use the new MongoDB driver. But I dont see any documentation for GridFS in that new driver. Does he lack…
user3018350
0
votes
1 answer

Meteor CollectionFS Collection is Undefined?

I am trying to use CollectionFS and GridFS to upload some images to my app and serve them back. I have the following definitions: ImageStore.js: var imageStore = new FS.Store.GridFS("images", { mongoUrl: 'mongodb://127.0.0.1:27017/test/', …
kidCoder
  • 354
  • 4
  • 17