我正在尝试向访问该应用的用户展示我上传的图片。
我仍然没有从我的项目中删除包insecured
或autopublish
。
我有一个像这样的功能:
$scope.upload = (event) => {
var file = event; //assuming 1 file only
console.log(file);
if (!file) return;
Images.insert(file, function (err, fileObj) {
if (err) {
console.log(err);
} else {
console.log('success', fileObj);
}
});
}
将图像存储在本地计算机中
Images = new FS.Collection("images", {
stores: [new FS.Store.FileSystem("images", {path: "/home/user/uploadedimages"})]
});
在我的meteor mongo
控制台中,当我show.collections
时,我得到cfs.images.filerecord
,其中包含以下内容:
{
"_id" : "yqEzEH2us7SZveDm2",
"original" : {
"name" : "Screenshot from 2016-05-11 14:38:59.png",
"updatedAt" : ISODate("2016-05-11T18:38:59.636Z"),
"size" : 607292,
"type" : "image/png"
},
"uploadedAt" : ISODate("2016-05-15T03:04:40.447Z"),
"copies" : {
"images" : {
"name" : "Screenshot from 2016-05-11 14:38:59.png",
"type" : "image/png",
"size" : 607292,
"key" : "images-yqEzEH2us7SZveDm2-Screenshot from 2016-05-11 14:38:59.png",
"updatedAt" : ISODate("2016-05-15T03:04:40Z"),
"createdAt" : ISODate("2016-05-15T03:04:40Z")
}
}
}
问题
如何将上传的图像显示给客户端。
我读过你做的事情
<div ng-repeat="image in images">
<img ng-src="{{image.url}}" width="400px" alt="">
</div>
但这不会渲染图像或显示任何内容。我知道我可以在没有订阅的情况下看到阵列,因为我仍然没有从meteor中删除autopublish
包。
答案 0 :(得分:2)
您可以使用var fileObj.url();在成功回调中获取上传图像的网址。例如:
List = [Pie]
Dict = {Apple}
for List in Dict:
print(Dict)
break