在流星应用中将mongofiles与GridFS一起使用 [英] Using mongofiles with GridFS in a meteor app

查看:71
本文介绍了在流星应用中将mongofiles与GridFS一起使用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我开始在Meteor应用程序中使用GridFS.我已经使用GridFS存储适配器设置了文件集合"assetFiles":

I am starting to use GridFS within a Meteor app. I have set up the file collection "assetFiles" with a GridFS storage adapter like this :

AssetCollection = new Mongo.Collection( "assets" );

AssetFileStore = new FS.Store.GridFS( "assetFiles" );
AssetFilesCollection = new FS.Collection( "assetFiles", {
    stores: [AssetFileStore]
});

AssetFilesCollection.allow({
  insert: function(){
    return true;
  },
  update: function(){
    return true;
  },
  remove: function(){
    return true;
  },
  download: function(){
    return true;
  }
});

我已经在其中插入了一些文件,并使用流星mongo客户端检查了它们是否确实存在于数据库中.

I have inserted some files in it and using meteor mongo client checked they actually exist in db.

现在,我想使用mongofiles实用程序将这个数据库中的文件提取到我的文件系统中.

Now I would like to extract a file from this db to my file system using mongofiles utility.

使用流星mongodb数据库,这是集合列表:

using the meteor mongodb database, here is the list of collections :

meteor:PRIMARY> show collections
assets
cfs._tempstore.chunks
cfs.assetFiles.filerecord
cfs_gridfs._tempstore.chunks
cfs_gridfs._tempstore.files
cfs_gridfs.assetFiles.chunks
cfs_gridfs.assetFiles.files
meteor_accounts_loginServiceConfiguration
system.indexes
users

我不明白如何使用mongofiles实用程序将我的assetFiles GridFS文件集合作为目标,以获取特定文件甚至文件列表.

And I don't understand how with the mongofiles utility I could target my assetFiles GridFS file collection to get a particular file or even a list of files.

这是我的尝试:

./mongofiles -h 127.0.0.1:3001 -d meteor list
2015-05-11T17:34:40.701+0200    connected to: 127.0.0.1:3001

在成功连接到db时,它什么也不会返回. 我的数据库位于我自己的FS上.我想指定一个集合名称,但是该参数显然不再存在.

It just returns nothing while successfully connecting to db. My db is on my own FS. I wanted to specify a collection name, but this parameter does not exists anymore apparently.

谢谢您的帮助!

推荐答案

,您需要更改前缀以附加到正确的集合.

you need to change the prefix to attach to the right collection.

$ mongofiles --help
       ....
       --prefix=                  GridFS prefix to use (default is 'fs')`

例如

mongofiles --port 3001 -d meteor --prefix 'cfs_gridfs.assetFiles' list

希望这会有所帮助! 接受,请谢谢!

hope this helps! accept please thanks!

这篇关于在流星应用中将mongofiles与GridFS一起使用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆