gpt4 book ai didi

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

转载 作者:可可西里 更新时间:2023-11-01 09:47:21 26 4
gpt4 key购买 nike

我可以在 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 驱动程序将这些文件放在哪里?

最佳答案

也许使用 mongo 管理实用程序查看 mongo 数据库并查看发生了什么会有所帮助。我用 phpMoAdmin .有了它,我可以看到所有的 Collection 品和 Collection 品中的元素。您也可以编辑元数据。至少这样你可以看到更广泛的事物。

关于java - 使用 mongofiles 实用程序访问通过 Java GridFS API 插入的数据,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4137837/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com