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

Sorting by metadata Mongodb's Nodejs driver

I'm using Gridfs to store files and allow the possibility of storing the same file but incrementing a version variable in the file's metadata. I'm using gridfs-stream to access the collection. So I'm trying to get the latest version out of the…
Will Huang
  • 325
  • 7
  • 15
0
votes
2 answers

MongoDB GridFS Get ID of a file

I am using MongoDB GridFS to store user avatars. I am using Laravel 4.2. I am writing a function to clean up the DB of any unused avatars; an avatar is unused if it's id is not associated with any user (User model). Given the ID of an avatar I can…
PeterKA
  • 24,158
  • 5
  • 26
  • 48
0
votes
0 answers

NodeJS, MongoDB data modelling for CSV data

Problem I have a CSV file with some data like…
Sameer Joshi
  • 877
  • 2
  • 9
  • 18
0
votes
0 answers

Retrieving image from mongoid gridFS using carrierwave gem not working

In my rails application , I uploaded files using carrierwave gem. When I am running my application and using local host as mongodb database its retrieving the image perfectly but when I am trying to use mongodb as remote system like 192.168.X.XX…
0
votes
1 answer

PHP MongoDB extract File Type

I've been working on GridFS with MongoDB + PHP and able to perform CRUD operations. I need to fetch the file extension types being uploaded. For example see below type that is being saved in Mongo for different file types: image = image/jpeg or…
Slimshadddyyy
  • 4,085
  • 5
  • 59
  • 121
0
votes
0 answers

Unable to download File from mongoDB GridFS in PHP

I am trying to make a small program for uploading and displaying files from mongoDB and PHP Uploading of files is being done properly. I have uploaded simple image files of 2-3MB to gridFS in mongoDB but my download code is giving Long array of…
theoneabhinav
  • 95
  • 1
  • 6
0
votes
1 answer

which to choose / select from collections i.e. chunks or files of mongoDB gridFS. on which basis we can decide this?

I am new to mongoDB and want to use it for storing files i.e. images and videos (size can be more than 40-50MB). For that we can use mongoDB gridFS. But in gridFS their are two collection i.e chunks and files. Now I want to know that which…
murtaza.webdev
  • 3,523
  • 4
  • 22
  • 32
0
votes
1 answer

Do you use nested document or multiple documents connected by IDs in MongoDB?

I have a "project" entity and each project can have many "models" (files and some metadata) and each model is associated with a "user". So far I have considered each of the entities as a document in MongoDB, However, I find myself going back to SQl…
Sami
  • 7,797
  • 18
  • 45
  • 69
0
votes
1 answer

File access permissions GridFS

All user-generated media files are stored in GridFS. Currently I need to implement some kind of access-system, based on permissions for files GridFS. For example, we have file in GridFS, called "passwords.txt", and only users, that have permission…
Dmitrijs Zubriks
  • 2,696
  • 6
  • 22
  • 33
0
votes
1 answer

How do I store large files using Meteor?

I'm building a Meteor (meteorjs) app that needs to store and display PDF files, sometimes as large as 500Mb. GridFS doesn't seem to be integrated yet so I'm wondering if it's worth using Meteor in this case or stick to Rails. Ideally I would not use…
0
votes
2 answers

How can a file (say image) be stored inside a MongoDB collection, using command line?

There is option of GridFS but that requires a driver(some language). Can't we insert a file in a table and display as a field(may b the path of file)? I tried one approach using Gridfs in python. from pymongo import MongoClient import gridfs db =…
Aman Kaushik
  • 83
  • 2
  • 8
0
votes
2 answers

How to put an image resized with Pillow into GridFS?

Scenario I use a formData form to upload an image via ajax which is then added to a MongoDB GridFS database. This was working: my_image = request.files.my_image raw = my_image.file.read() fs.put(raw) Desired Behaviour I want to resize the image…
user1063287
  • 10,265
  • 25
  • 122
  • 218
0
votes
1 answer

List all GridFs metadata only using mongoose on nodejs

recently I've been struggling on how can I list all the metadata only of GridFs collection using mongoose. I've tried using this var mongoose = require('mongoose'); public.schema = { filename : { type: String, required: true }, …
Alleo Indong
  • 327
  • 3
  • 13
0
votes
1 answer

Converting GridFS file object to File object to upload via carriewave then process with ffmpeg in Rails

I have a GridFS file object Mongoid::GridFs::Fs::File _id: 53a277dc700ca7ac146f5797, length: 2237337, chunkSize: 261120, uploadDate: 2014-06-19 05:40:44 UTC, md5: "390968a8ef198f8537495468366f67b9", filename: "720p_5.MP4", contentType:…
Ojash
  • 1,234
  • 8
  • 20
0
votes
2 answers

Canvas dataurl saving to Mongodb data grid using PHP

I am drawing an image in a canvas and passing the canvas dataURL through AJAX to a PHP code to store it in Mongo DB gridFS. While I am able to get the data URL and able to store the file but when I retrieve to show the image it does not show the…
Shantanu
  • 13
  • 4