Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6948921
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T13:53:10+00:00 2026-05-27T13:53:10+00:00

I have a blogging system that stores uploaded files into the GridFS system. Problem

  • 0

I have a blogging system that stores uploaded files into the GridFS system. Problem is, I dont understand how to query it!

I am using Mongoose with NodeJS which doesnt yet support GridFS so I am using the actual mongodb module for the GridFS operations. There doesn’t SEEM to be a way to query the files metadata like you do documents in a regular collection.

Would it be wise to store the metadata in a document pointing to the GridFS objectId? to easily be able to query?

Any help would be GREATLY appreciated, im kinda stuck :/

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T13:53:10+00:00Added an answer on May 27, 2026 at 1:53 pm

    GridFS works by storing a number of chunks for each file. This way, you can deliver and store very large files without having to store the entire file in RAM. Also, this enables you to store files that are larger than the maximum document size. The recommended chunk size is 256kb.

    The file metadata field can be used to store additional file-specific metadata, which can be more efficient than storing the metadata in a separate document. This greatly depends on your exact requirements, but the metadata field, in general, offers a lot of flexibility. Keep in mind that some of the more obvious metadata is already part of the fs.files document, by default:

    > db.fs.files.findOne();
    {
        "_id" : ObjectId("4f9d4172b2ceac15506445e1"),
        "filename" : "2e117dc7f5ba434c90be29c767426c29",
        "length" : 486912,
        "chunkSize" : 262144,
        "uploadDate" : ISODate("2011-10-18T09:05:54.851Z"),
        "md5" : "4f31970165766913fdece5417f7fa4a8",
        "contentType" : "application/pdf"
    }
    

    To actually read the file from GridFS you’ll have to fetch the file document from fs.files and the chunks from fs.chunks. The most efficient way to do that is to stream this to the client chunk-by-chunk, so you don’t have to load the entire file in RAM. The chunks collection has the following structure:

    > db.fs.chunks.findOne({}, {"data" :0});
    {
        "_id" : ObjectId("4e9d4172b2ceac15506445e1"),
        "files_id" : ObjectId("4f9d4172b2ceac15506445e1"),
        "n" : 0, // this is the 0th chunk of the file
        "data" : /* loads of data */
    }
    

    If you want to use the metadata field of fs.files for your queries, make sure you understand the dot notation, e.g.

    > db.fs.files.find({"metadata.OwnerId": new ObjectId("..."), 
                        "metadata.ImageWidth" : 280});
    

    also make sure your queries can use an index using explain().

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a system that is performing many XSL transformations on XMLType objects. The
Say I have a blogging site http://www.example.com using custom cms, and I want each
Hey all. I'm scripting a blogging system for my website. So I have this
Hey all. I'm scripting a blogging system for my website. So I have this
I have a Rails app that is a blogging platform, allowing for multiple contributing
I want to have sort of live blogging that will allow a reporter to
I wrote a blogging system from scratch ( http://seanhess.net ). I have the last
I am creating a mongodb/nodejs blogging system (similar to wordpress). I currently have the
I have been looking for a proper comment system for my blogging site. I
Say I have a blogging app in Django. How can i re-order the posts

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.