Use mongofiles utility to access data inserted with Java GridFS API
I can successfully insert and retrieve data from MongoDB's GridFS in Java. However, when I try to access that data on the command line using mongofiles, I can't find it. The Java insertion code:
GridFS fs = new GridFS(Mongo.getStaticMongo("localhost:开发者_开发问答27017").getDB("myDb"), "myCollection");
try {
GridFSInputFile inputFile = fs.createFile(content.getFile());
inputFile.put(MONGO_KEY, content.getId().toString());
inputFile.save();
} catch (IOException e) {
throw new RuntimeException(e);
}
The command line:
>mongofiles --host localhost:27017 -d myDb -c myCollection -vvvvvv list
Tue Nov 09 11:48:01 creating new connection to:localhost:27017
connected to: localhost:27017
>
Nothing comes back... where is the Java GridFS driver putting these files?
Perhaps it would be beneficial to use a mongo admin utility to look in the mongo database and see what happened. I use phpMoAdmin. With it I can see all of the collections and items in the collections. You can also edit the metadata too. At least this way you can see things on a wider scale.
The mongofiles
command line tool only works with the default 'fs' bucket.
There is an open JIRA item to address this: https://jira.mongodb.org/browse/SERVER-1970
精彩评论