Meteor-Community-Packages/Meteor-CollectionFS

我想问一个简单的问题,图片上传后,怎么显示出来

eugle opened this issue · 2 comments

eugle commented

我看了很多资料和官方的教程说明,都说在
{{#each images}} < i m g src='{{this.url}}' > {{/each}}

就可以显示出来,但是,不管是程序默认的还是设置了 /data目录,他都是 /cfs...这种格式的,并且根本显示不出来,请问怎么解决,求给一段能用的代码或告诉方法,到底是怎么才能显示出来,已经研究一整天了,都没有办法

==============================

I looked at a lot of information and the official instructions, and they all said

{{#each images}} < i m g src='{{this.url}}' > {{/each}}

It can be displayed, but whether it's the default or set/data directory, he's/CFS... This format, and the ultimate show not to come out, how can I solve, can give a of the code or tell method, how to display, has been studying all day long, all have no way

12121212212121212

123

32

14

You try to get the image from the thumbs store..

<img src={{this.url store="thumbs"}}>

...but only the images store got created..

stores:[new FS.Store.Filesystem("images")]

Solution 1:

..use the one store you created

<img src={{this.url store="images"}}>

Solution 2:

.. add a thumbs store
from https://github.com/CollectionFS/Meteor-CollectionFS#basic-example

var createThumb = function(fileObj, readStream, writeStream) {
  // Transform the image into a 10x10px thumbnail
  gm(readStream, fileObj.name()).resize('10', '10').stream().pipe(writeStream);
};

Images = new FS.Collection("images", {
  stores: [
    new FS.Store.FileSystem("thumbs", { transformWrite: createThumb }),
    new FS.Store.FileSystem("images"),
  ],
  filter: {
    allow: {
      contentTypes: ['image/*'] //allow only images in this FS.Collection
    }
  }
});
eugle commented

这是对的,我已经解决显示的问题,感谢你

That's right. I've solved the problem. Thank you very much~!!