【问题标题】:mongodb gridfs to flat filesmongodb gridfs到平面文件
【发布时间】:2014-02-25 19:43:10
【问题描述】:

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

  foo.files.bson
  foo.chunks.bson

我使用 mongorestore 导入了它们。 但是现在如何将每个对象转储到外部文件? 所有长度约为 29,000,而块大小 是 262,144,所以这些块应该是自包含的。

> 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 gridfs


    【解决方案1】:

    如果我正确理解您的问题,您想读取导入转储中的文件 - 此作业的 mongodb 客户端工具是 mongofiles - http://docs.mongodb.org/manual/reference/program/mongofiles/

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

    【讨论】:

      猜你喜欢
      • 2015-08-22
      • 2015-07-18
      • 2014-04-28
      • 2012-03-22
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多