使用 mongofiles 实用程序访问通过 Java GridFS API 插入的数据

发布于 2024-10-02 01:12:01 字数 689 浏览 1 评论 0原文

我可以使用 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

辞慾 2024-10-09 01:12:01

也许使用 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.

蒲公英的约定 2024-10-09 01:12:01

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

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文