【发布时间】:2016-01-27 17:53:41
【问题描述】:
我正在尝试让 autoform-file 工作 (https://github.com/yogiben/meteor-autoform-file),但它似乎根本没有做任何事情。
根据快速入门,我已完成以下操作:
1) 定义了具有正确权限的集合:
Images = new FS.Collection("images", {
stores: [new FS.Store.FileSystem("images", {path: "~/meteor_uploads"})]
});
Images.allow({
insert: function (userId, doc) {
return true;
},
download: function (userId) {
return true;
}
});
2) 发表了我的收藏:
Meteor.publish('images', function () {
Meteor.Images.find({});
});
3) 更新我的路由器等待订阅:
Router.route('/test', {
waitOn: function () {
Meteor.subscribe('images');
},
action: function () {
this.render('test', {to: 'main'});
}
});
4) 定义模式:
Test.attachSchema(new SimpleSchema({
userName: {
type: String,
label: "Title",
max: 100
},
userImg: {
type: String,
autoform: {
afFieldInput: {
type: 'fileUpload',
collection: 'Images',
label: 'Upload a file'
}
}
},
}));
5) 在我的“测试”模板中使用了快速表单:
{{> quickForm collection="Test" type="insert"}}
快速表单显示在模板中,并带有一个按钮,上面写着“在文件上上传”,如架构中定义的那样。当我单击按钮时,我可以浏览并单击本地文件系统中的文件。但是,当我单击快速表单中的提交按钮时,我收到一条错误消息“需要用户 img”。
这让我感到莫名其妙。我在快速入门中完美地遵循了这些步骤(我认为),但它根本没有做任何事情......有人知道我哪里出错了吗?
【问题讨论】: