Upload multiple files into Mongodb through Shell

930 views
Skip to first unread message

tma...@auspicate.com

unread,
Apr 7, 2015, 10:17:14 AM4/7/15
to mongod...@googlegroups.com
Hi 

Can anyone help me to upload multiple files with one single command(like put) through shell, I have uploaded a file into mongodb by using put command through shell. I don't want go for c# coding which will use Gridfs.

If Gridfs can be used in shell, please let me know the query command for shell.

Thanks in advance




Will Berkeley

unread,
Apr 7, 2015, 10:38:12 AM4/7/15
to mongod...@googlegroups.com
The mongo shell doesn't have a GridFS interface. If you don't want to write a C# program to insert multiple files, you could write a lightweight script, say using mongofiles and a shell script or using the Python driver's gridfs package.

-Will

Tulasi Madisa

unread,
Apr 7, 2015, 10:43:28 AM4/7/15
to mongod...@googlegroups.com

I have uploaded single file ( mongofiles put recovery.json) using shell script. I have tried ( mongofiles put directorypath.*)  unfortunately it did not work. Can you let me know the query(command)



On Tue, Apr 7, 2015 at 8:08 PM, Will Berkeley <william....@mongodb.com> wrote:
The mongo shell doesn't have a GridFS interface. If you don't want to write a C# program to insert multiple files, you could write a lightweight script, say using mongofiles and a shell script or using the Python driver's gridfs package.

-Will

--
You received this message because you are subscribed to the Google Groups "mongodb-user"
group.
 
For other MongoDB technical support options, see: http://www.mongodb.org/about/support/.
---
You received this message because you are subscribed to a topic in the Google Groups "mongodb-user" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/mongodb-user/8pN0I97hac4/unsubscribe.
To unsubscribe from this group and all its topics, send an email to mongodb-user...@googlegroups.com.
To post to this group, send email to mongod...@googlegroups.com.
Visit this group at http://groups.google.com/group/mongodb-user.
To view this discussion on the web visit https://groups.google.com/d/msgid/mongodb-user/891c1878-6c77-4cb2-b7e8-cc125998849c%40googlegroups.com.

For more options, visit https://groups.google.com/d/optout.



--
Thanks and Regards
Tulasi

Stephen Steneker

unread,
Apr 8, 2015, 7:00:19 AM4/8/15
to mongod...@googlegroups.com
On Wednesday, 8 April 2015 00:43:28 UTC+10, Tulasi Madisa wrote:
I have uploaded single file ( mongofiles put recovery.json) using shell script. I have tried ( mongofiles put directorypath.*)  unfortunately it did not work. Can you let me know the query(command)

Hi Tulasi,

The `mongofiles` command line tool is a fairly basic helper. If you want to do anything more advanced you could either use the GridFS API via a MongoDB driver, or perhaps cook up a loop in a bash shell script or similar.

You may want to raise a feature suggestion in the TOOLS project (component "mongofiles") to see if others would find this useful.

Regards,
Stephen

Tulasi Madisa

unread,
Apr 14, 2015, 10:48:16 AM4/14/15
to mongod...@googlegroups.com
Hi Stephen

Can you please help me with the javascript code for uploading files in bulk into mongodb. I am getting any clue on how to start this. Please check the url below, I have tried to insert using the same syntax ("mongofiles -d put a.pdf b.pdf" & "mongofiles -d put c:\..\" ) unfortunately both the ways did not work. Can you please help me understand the syntax given in the url


Thanks in advance

--
You received this message because you are subscribed to the Google Groups "mongodb-user"
group.
 
For other MongoDB technical support options, see: http://www.mongodb.org/about/support/.
---
You received this message because you are subscribed to a topic in the Google Groups "mongodb-user" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/mongodb-user/8pN0I97hac4/unsubscribe.
To unsubscribe from this group and all its topics, send an email to mongodb-user...@googlegroups.com.
To post to this group, send email to mongod...@googlegroups.com.
Visit this group at http://groups.google.com/group/mongodb-user.

For more options, visit https://groups.google.com/d/optout.

Stephen Steneker

unread,
Apr 21, 2015, 3:26:31 AM4/21/15
to mongod...@googlegroups.com
On Wednesday, 15 April 2015 00:48:16 UTC+10, Tulasi Madisa wrote:
Can you please help me with the javascript code for uploading files in bulk into mongodb. I am getting any clue on how to start this. Please check the url below, I have tried to insert using the same syntax ("mongofiles -d put a.pdf b.pdf" & "mongofiles -d put c:\..\" ) unfortunately both the ways did not work. Can you please help me understand the syntax given in the url


Hi Tulasi,

Apologies .. thought I'd already posted a reply to your last comment but it seems to have gone astray :(.

The "put" documentation you've referenced here is for WinSCP, which is unrelated to saving files to GridFS with the `mongofiles` command line tool:
 http://docs.mongodb.org/manual/reference/program/mongofiles/

Since the `mongofiles` command only accepts a single filename as a parameter, you would have to call `mongofiles --put filename` for each file you want to upload. I think a better alternative would be to bulk upload files using the GridFS API via your favourite programming language.

I've also created a feature suggestion to add support for wildcard filenames to `mongofiles` if you'd like to upvote/watch this:
 https://jira.mongodb.org/browse/TOOLS-720

That won't help you in the short term, but it seems like it might be a useful feature to add.

Regards,
Stephen

Tulasi Madisa

unread,
Apr 21, 2015, 4:53:27 AM4/21/15
to mongod...@googlegroups.com
Thanks Stephen

--
You received this message because you are subscribed to the Google Groups "mongodb-user"
group.
 
For other MongoDB technical support options, see: http://www.mongodb.org/about/support/.
---
You received this message because you are subscribed to a topic in the Google Groups "mongodb-user" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/mongodb-user/8pN0I97hac4/unsubscribe.
To unsubscribe from this group and all its topics, send an email to mongodb-user...@googlegroups.com.
To post to this group, send email to mongod...@googlegroups.com.
Visit this group at http://groups.google.com/group/mongodb-user.

For more options, visit https://groups.google.com/d/optout.
Reply all
Reply to author
Forward
0 new messages