使用 mongofiles 实用程序访问通过 Java GridFS API 插入的数据
我可以使用 Java 成功地从 MongoDB 的 GridFS 插入和检索数据。但是,当我尝试使用 mongofiles 在命令行上访问该数据时,我找不到它。 Java 插入代码:
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);
}
命令行:
>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
>
什么也没有返回... Java GridFS 驱动程序将这些文件放在哪里?
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?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
也许使用 mongo 管理实用程序来查看 mongo 数据库并查看发生了什么会很有帮助。我使用 phpMoAdmin。有了它,我可以看到所有的集合和集合中的项目。您也可以编辑元数据。至少这样你可以从更广阔的角度看待事物。
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.
mongofiles
命令行工具仅适用于默认的“fs”存储桶。有一个开放的 JIRA 项目可以解决此问题: https://jira.mongodb.org/browse/SERVER -1970
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