【问题标题】:Meteor-CollectionFS gridfs images does not showMeteor-CollectionFS gridfs 图像不显示
【发布时间】:2015-08-03 22:05:56
【问题描述】:

这是一次使用gridfs上传和显示图片的尝试。

这放置在服务器和客户端上:

var imageStore = new FS.Store.GridFS("images", {});
Images = new FS.Collection("images", {
  stores: [imageStore],
  filter: {
    maxSize: 6048576 // in bytes
  }
});

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

模板:

<template name="imageView">
    <div class="imageView">
        {{#each images}}
        <div>
            <img src="{{this.url store='images'}}" alt="" class="thumbnail" />
        </div>
        {{/each}}
    </div>
</template>

此模板的助手:

Template.imageView.helpers({
  images: function () {
    return Images.find(); // Where Images is an FS.Collection instance
  }
});

我发布图片集:

Meteor.publish("images", function () {
  return Images.find({});
});

我在我的路线中订阅了这些图片:

waitOn: function () {
  return this.subscribe('images');
}

其中大部分是从 collectionFS github 页面复制粘贴的,但它仍然没有显示任何图像。这是上传图片后在我的数据库中的外观:

image1 image2 image3

现在这有什么问题?我仍然没有看到任何图像。

【问题讨论】:

    标签: meteor collectionfs


    【解决方案1】:

    您的商店名称是registrationStorage,您的收藏名称是registrations。尝试将第二个 sn-p 的第二行更改为:

     <img src="{{this.url store="registrationStorage"}}" /><br />
    

    【讨论】:

    • 如果我将其更改为“registrationStorage”,那么 标记将根本不会显示在页面源中。
    • 如果你给它提供一个随机的商店名称,它会吗? cfs:dropbox 可能有问题... GitHub 页面说它还没有准备好投入生产,并且仍然存在错误。我正在使用 sfs:gridfs 并且它工作得很好,所以如果它适合你,请考虑使用它。
    • 我将帖子编辑为与 gridfs 一起使用的内容,但仍然无法正常工作。我也有同样的问题。
    • 等一下,我刚刚在我的 mac 笔记本电脑上试过这个,它可以工作,但它不能在 windows pc 上工作。
    猜你喜欢
    • 2015-06-01
    • 1970-01-01
    • 2015-12-12
    • 2018-12-31
    • 1970-01-01
    • 2015-06-02
    • 2014-04-08
    • 2017-06-23
    • 2016-03-21
    相关资源
    最近更新 更多