【问题标题】:Get a file out of MongoDB GridFS with no filename with mongofiles使用 mongofiles 从 MongoDB GridFS 中获取没有文件名的文件
【发布时间】:2013-06-01 19:17:07
【问题描述】:

GridFS中有文件:

In [1]: import pymongo

In [2]: c = pymongo.Connection('localhost', 49996)

In [3]: gfsf = c.wss_test.fs.files.find()

In [4]: gfsf.next()
Out[4]: 
{u'_id': ObjectId('51ad37067662579917000000'),
 u'chsum': u'18848aca1fc0980524d84aed3cc87dce',
 u'chunkSize': 1048576L,
 u'compressed': 0L,
 u'creationDate': u'2013-06-04T00:38:30',
 u'json': 1L,
 u'length': 15L,
 u'md5': u'18848aca1fc0980524d84aed3cc87dce',
 u'uploadDate': datetime.datetime(2013, 6, 4, 0, 38, 30)}

但是 mongofiles 只吐出长度 - 没有文件名:

$ mongofiles -h localhost:49996 -d wss_test list
connected to: localhost:49996
    15
    62
    14

由于所有mongofiles 操作都是按文件名,现在怎么办?

【问题讨论】:

    标签: mongodb filenames gridfs


    【解决方案1】:

    是的,mongofiles 仅适用于文件名,这在 GridFS 规范中是完全可选的。如果您需要通过 mongofiles 处理文件,请确保将文件名添加到文件中。

    【讨论】:

      猜你喜欢
      • 2021-07-06
      • 1970-01-01
      • 1970-01-01
      • 2015-12-21
      • 2017-10-09
      • 1970-01-01
      • 2015-09-01
      • 2012-06-24
      • 1970-01-01
      相关资源
      最近更新 更多