【发布时间】:2015-11-25 18:40:53
【问题描述】:
我的代码: 服务器/app.js
var imageLargeStore = new FS.Store.S3("imagesLarge", {
accessKeyId: "xxxx",
secretAccessKey: "xxx",
bucket: "profile-thumbs",
transformWrite: function(fileObj, readStream, writeStream) {
gm(readStream, fileObj.name()).resize('250', '250').stream().pipe(writeStream)
}
});
var imageSmallStore = new FS.Store.S3("imagesSmall", {
accessKeyId: "xxxx",
secretAccessKey: "xxx",
bucket: "profile-thumbs",
transformWrite: function(fileObj, readStream, writeStream) {
gm(readStream, fileObj.name()).resize('80', '80').stream().pipe(writeStream)
}
});
thumbs = new FS.Collection("images", {
stores: [imageLargeStore,imageSmallStore]
});
Meteor.publish("images", function() {
return thumbs.find();
});
thumbs.allow({
insert: function (userId, doc) {
return true;
},
update: function (userId, doc, fields, modifier) {
return true;
},
remove: function (userId, doc) {
return true;
},
download:function(){
return true;
}
});
client/app.js
var imageLargeStore = new FS.Store.S3("imagesLarge");
var imageSmallStore = new FS.Store.S3("imagesSmall");
thumbs = new FS.Collection("images", {
stores: [imageLargeStore,imageSmallStore],
filter: {
allow: {
contentTypes: ['image/*']
}
}
})
上传工作正常,我可以在 aws 中看到图像
thumbs.insert(res,function(err,fileobj){
console.log(fileobj);
})
我在客户端发布并订阅了所有集合
我尝试显示图像,但它们没有显示
{{#each images}}
<div>
<a href="{{this.url}}" target="_blank"><img src="{{this.url store='imageSmallStore' uploading='/amazon.png' storing='/angjs.jpg'}}" alt="" class="thumbnail" /></a>
</div>
{{/each}}
images:function(){
return thumbs.find({});
}
但是图像没有显示,而不是存储图像(angjs.jpg)正在显示。
当我检查元素时,我可以看到类似的 url
但是图片没有显示,我的代码有什么问题?
当我尝试在 aws 控制台中打开 Image 时遇到此错误
【问题讨论】:
-
如果你把这个你得到什么?
<a href="{{this.url}}" target="_blank"><img src="{{this.url store='imageSmallStore' }}" alt="" class="thumbnail" /></a> -
@Ethaan,不,那不行
-
您找到解决方案了吗?我也遇到了类似的事情
标签: meteor