【问题标题】:Meteor autoform-file not working流星自动生成文件不起作用
【发布时间】: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”。

这让我感到莫名其妙。我在快速入门中完美地遵循了这些步骤(我认为),但它根本没有做任何事情......有人知道我哪里出错了吗?

【问题讨论】:

    标签: meteor meteor-autoform


    【解决方案1】:

    原来 cfs:filesystem 包不适用于 autoform-file。我换成了 GridFS,现在可以正常使用了。

    【讨论】:

      猜你喜欢
      • 2017-12-25
      • 1970-01-01
      • 2015-09-23
      • 1970-01-01
      • 2018-03-21
      • 2015-09-14
      • 1970-01-01
      • 2012-07-20
      相关资源
      最近更新 更多