mongodb gridfs到平面文件

mongodb gridfs到平面文件,mongodb,gridfs,Mongodb,Gridfs,如何将转储的mongodb转换为平面文件? 我继承了一个mongodb和一个gridfs foo.files.bson foo.chunks.bson 我用mongorestore进口的。 但现在如何将每个对象转储到外部文件? 所有长度约为29000,而块大小 是262144,因此块应该是自包含的 > db.foo.files.find()[0] { "_closed" : true, "_id" : ObjectId("4e9c69e93e3c092c02000

如何将转储的mongodb转换为平面文件? 我继承了一个mongodb和一个gridfs

  foo.files.bson
  foo.chunks.bson
我用mongorestore进口的。 但现在如何将每个对象转储到外部文件? 所有长度约为29000,而块大小 是262144,因此块应该是自包含的

> db.foo.files.find()[0]
{
    "_closed" : true,
    "_id" : ObjectId("4e9c69e93e3c092c02000001"),
    "chunkSize" : 262144,
    "comment" : ObjectId("4e9c69e93e3c092c02000000"),
    "compression" : "bz2",
    "filename" : "my/file",
    "is_dft" : true,
    "is_gw" : false,
    "length" : 22760,
    "md5" : "f58c497a0f6127fe70f8240c12d482b6",
    "sha512" : "19e3...a2338",
    "uploadDate" : ISODate("2011-10-17T17:46:17.312Z"),
    "uploader" : null
}


> db.OUTCARs.chunks.find()[0]
{
    "_id" : ObjectId("4e9c69e93e3c092c02000002"),
    "n" : 0,
    "data" : BinData(0,"QlpoOTFsEAjf...UJA8CxbBA="),  ******* this is the data to save to a flat file
    "files_id" : ObjectId("4e9c69e93e3c092c02000001")
}

如果我正确理解您的问题,您希望读取导入转储中的文件-此作业的mongodb客户端工具是mongofiles-

只需在命令提示符/终端上键入mongofiles,您将看到子命令,如put/get/list/search。答案在于使用get和list