meteor fs.collection 500插入图像后出错
我正在尝试使用FS.Collection2库在meteor中上传工作图像 我设法上传图片并显示它们,但在插入图片后,我出现以下服务器错误(我只插入,不更新任何内容) 这是我的代码: 插入:meteor fs.collection 500插入图像后出错,meteor,Meteor,我正在尝试使用FS.Collection2库在meteor中上传工作图像 我设法上传图片并显示它们,但在插入图片后,我出现以下服务器错误(我只插入,不更新任何内容) 这是我的代码: 插入: FS.Utility.eachFile(event, function(file) { Images.insert(file, function (err, fileObj) { console.log(err); }); }); 收藏: Images = new FS.Co
FS.Utility.eachFile(event, function(file) {
Images.insert(file, function (err, fileObj) {
console.log(err);
});
});
收藏:
Images = new FS.Collection("images", {
stores: [new FS.Store.FileSystem("images")]
});
if (Meteor.isServer) {
Images.allow({
insert: function (fileID, doc) {
return true;
},
update: function (fileID, doc) {
return true;
},
remove: function(userId, doc) {
return false;
},
download: function (fileID, doc) {
return true;
}
});
}
FS软件包版本:
cfs:filesystem 0.1.1
cfs:standard-packages 0.5.3
谢谢,希望你能给我指出正确的方向
我添加了错误的屏幕截图
在你的meteor应用程序上试试这个,告诉我是否有效 首先,要更好地声明
/lib/Collections.js文件夹中的集合,请使用以下命令
Images = new FS.Collection("images", {
stores: [new FS.Store.FileSystem("images")]
});
if(Meteor.isClient) {
Meteor.subscribe('Images');
}
同样在meteor控制台上,meteor remove autopublish Unsecure
,这样您就可以确保所有集合的安全,而且meteor首先会将其加载到/lib
,文件夹中,这样集合现在在客户端/服务器上都可用
现在在/server/collections.js上
Meteor.publish('Images', function(){
return Images.find();
});
Images.allow({
insert: function(userId, doc) { return true; },
update: function(userId,doc) { return true; },
remove: function(userId,doc) { return false; },
download: function(userId, doc) {return true;},
});
现在,在/client/insertingImages.html
中,使用一些简单的示例
<template name="example">
<input id="addImage" type="file">
<button type="submit" id="loadImage"> Click to add Image</button>
</template>
告诉我这是否有效如果您还没有弄清楚如何操作,请在项目目录的控制台中执行以下命令:
meteor remove audit-argument-checks
这将修复错误。Hi Etjana,非常感谢您的回复(我完全按照您所说的粘贴代码),它的行为方式完全相同。上载并保存图片,但插入后出现服务器错误。我在allow
上粘贴了两个errorRemoveuserId,doc
参数的屏幕截图,问题似乎来自服务器代码,它抱怨没有检查所有参数,尝试删除2个参数,我修复了它,我删除了审计参数检查数据包,其中存在一些不兼容问题。但是谢谢你的回复!!:)
Template.example.events({
'click #loadImage' : function(template,event){
var file = $('#addImage').get(0).files[0],
metadataText = "this is some cool metadata text on the image";
fsFile = new FS.File(file);
fsFile.metadata = {textFile:metadataText}
//Some authentication,(if not file selected cannot upload anything)
if(file === undefined){
alert("SORRY YOU NEED TO UPLOAD AN IMAGE TO CONTINUE");
} else{
Images.insert(fsFile,function(err,succes){
if(err){
console.log(err.reason);
} else{
console.log(succes); //this should return the fsFile, or the Id of fsFile
}
}
}
}
})
meteor remove audit-argument-checks