Using mongofiles with GridFS in a meteor app

佐手、 提交于 2019-12-02 05:50:16

问题


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;
  }
});

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

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

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

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.

Here is my attempt:

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

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.

Thank you for your help!


回答1:


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

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

eg.

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

hope this helps! accept please thanks!



来源:https://stackoverflow.com/questions/30172205/using-mongofiles-with-gridfs-in-a-meteor-app

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!