Javascript 第一个请求返回503刚刚上传到Meteor GridFS的图像
有人能告诉我为什么会发生这种错误以及如何解决它吗? 当我重新加载页面(cmd+r)时,图像请求工作正常 来自浏览器控制台的错误:Javascript 第一个请求返回503刚刚上传到Meteor GridFS的图像,javascript,meteor,gridfs,Javascript,Meteor,Gridfs,有人能告诉我为什么会发生这种错误以及如何解决它吗? 当我重新加载页面(cmd+r)时,图像请求工作正常 来自浏览器控制台的错误: <template name="profileedit"> <img src="{{imgsrc}}" style="width:400px" > </template> 503(服务不可用) 发生了什么: <template name="profileedit"> <img src="{{imgsrc}
<template name="profileedit">
<img src="{{imgsrc}}" style="width:400px" >
</template>
503(服务不可用)
发生了什么:
<template name="profileedit">
<img src="{{imgsrc}}" style="width:400px" >
</template>
Template.profileedit.events({
'change .myFileInput': function(event, template) {
var files = event.target.files;
for (var i = 0, ln = files.length; i < ln; i++) {
Images.insert(files[i], function (err, fileObj) {
var userId = Meteor.userId();
var imagesURL = {
"profile.image": "/cfs/files/images2/" + fileObj._id
};
Meteor.users.update(userId, {$set: imagesURL});
});
}
}
显示图像的HTML:
<template name="profileedit">
<img src="{{imgsrc}}" style="width:400px" >
</template>
其他东西
这个问题在本地和meteor.com上都是一样的
不安全且自动发布处于活动状态(这只是学习步骤)
谢谢
Jesper我可以想象您遇到了一个问题,Mongo还没有准备好检索对象。我的猜测是,反应式更新发生在您的图像实际可供检索之前,但当您点击“刷新”按钮时,它已经存在并准备好被检索,这就是为什么这种变通方法可以工作的原因
有几种方法可以解决这个问题。例如:基本上允许您设置一个“等待”图像,该图像将在您的文件未准备好时显示,并在您的图像设置为要检索时进行反应性更新。您也可以通过显示的实现自行完成此操作。还有其他更好的方法来解决此问题吗?当图像准备就绪并调用页面渲染时是否有回调?