Meteor正确保存图像但我无法检索它们

时间:2014-11-18 12:26:04

标签: meteor

使用以下集合;

var imageStore = new FS.Store.S3("images", {   bucket: "my-bucket" });

Images = new FS.Collection("images", {   stores: [imageStore] });

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

我可以成功存储和上传图像到S3 - 图像上传很好,并保存在Mongo DB中。

但是当我这样做的时候;

Images.find().count()

它将返回0

Images.find().fetch()

返回一个空数组。

如果我运行meteor mongo并使用查询db.cfs.images.filerecord.find().count(),则会返回6(正确的数字)

想知道我在这里做错了什么?

1 个答案:

答案 0 :(得分:1)

如果您已删除自动发布,请不要忘记发布您的images收藏集。

服务器

Meteor.publish("images", function() {
    return Images.find(); //Narrow this down to the images that should be viewable
});

然后在客户端:

Meteor.subscribe("images");