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 8150117
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T14:59:13+00:00 2026-06-06T14:59:13+00:00

How, through the mongo shell, do I upload a file to my MongoDB and

  • 0

How, through the mongo shell, do I “upload” a file to my MongoDB and how to I retrieve that same file? I wonder, what is the output, even, after doing so.

I think showing what I’ve done will show how foolish my attempts have been.

db.fs.files.insert("foo.txt");

This just seems to insert the actual text not the document I want…and to retrieve, I found that

db.fs.files.retrieve()

Isnt a function. find() just displays to me…but I want the actual document’s contents printed, whether it be BINARY data or w/e I don’t care, haha.

I’m sorry for such miserable attempts – but perhaps it showcases how little I know of what GridFS can do – maybe someone can clear that up for me in addition to the usage.

  • 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-06-06T14:59:15+00:00Added an answer on June 6, 2026 at 2:59 pm

    From command line you can use mongofiles: http://www.mongodb.org/display/DOCS/GridFS+Tools

    mongofiles put yourfile.txt
    cd /tmp
    mongofiles get yourfile.txt
    

    The first line puts the file yourfile.txt to the mongodb. The second one retrieves it at another position in the file system.

    I think it is not possible to use GridFS directly from the mongo shell.

    From python you can use:

        class gridfs.GridFS(database, collection='fs')
    

    http://api.mongodb.org/python/current/api/gridfs/index.html#gridfs.GridFS

    For what GridFS should be used:

    http://www.mongodb.org/display/DOCS/When+to+use+GridFS

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

Sidebar

Related Questions

I am trying to retrieve all cards from Mongoid that have request=preview I'm doing
I've got a node.js script that loads an XML file. It loops through each
After sitting through a session today on Mono at a local .Net event, the
through java reflection how to check that method name is in camelCase? e.g. import
Through Xcode 4.3 ->file -> source control -> repositories -> clone repository, I've cloned
We use MongoDB to collect logs on pageviews. $collection_name = logs..date('Y')...date('m')...date('d'); $collection = $this->Mongo->$collection_name;
I switched my mongodb environment from replication-sets to sharding with replication-sets through mongos. I
today I updated my Mongo.. mongodb-stable (from 10gen repo) but my service has down.
Possible Duplicate: Mongo interface I have been going through the GUI tools available for
I want to execute mongo commands in shell script, e.g. in a script test.sh

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.