我正在使用FS.Collection包来插入和存储图像。问题是我不能每次提交多于一个文件。如何启用它?这是我的插入功能:
// Upload images
'change #exampleInput':function(event, template){
// Get Session with 4 words password
var fourWords = Session.get("fourWords");
var file = $('#exampleInput').get(0).files[0] //Some jQuery to get the value.
fsFile = new FS.File(file);
// Store 4 words password in metadata
fsFile.metadata = {
fourWords:fourWords,
}
// Insert into Image Collection
Images.insert(fsFile,function(err,result){
if(!err){
console.log(result)
}
})
}
答案 0 :(得分:1)
这应该有用。
// Upload images
'change #exampleInput':function(event, template){
// Get Session with 4 words password
var fourWords = Session.get("fourWords");
FS.Utility.eachFile(event, function(file) {
file = $('#exampleInput').get(0).files[0], // or use event.target.files;
fsFile = new FS.File(file);
fsFile.metadata = {
fourWords:fourWords,
}
Images.insert(file, function (err, fileObj) {
});
});
}
这项工作对我来说,但我不喜欢使用多个文件上传,当您将超过10-15个图像上传到集合中时会出现一个问题,lag issue。