1

在我将流星从(1.0.5 升级到 1.1.2)之后,当我尝试使用 cfs:autoform 上传文件时,它拒绝保存文件。就像我会选择一个文件并单击提交一样,但它会抛出一个错误并告诉我该文件不存在(该字段是必需的)。这是一个没有错误还是我做错了什么?我把我的代码放在下面:

<template name="school_create">
<div class="header">School Create</div>

{{#autoForm collection="Schools" id="school_create" type="insert"}}
<fieldset>
  <legend>Add a School</legend>
  <div style="float:left">
    <div class="textField">
      {{> afQuickField name='name'}}
    </div>
    <div class="textField" style="margin-left:20px;">
      {{> afQuickField name='sub_domain'}}
    </div>

  </div>
  <div class="descriptionText">
    {{> afQuickField name='image' type="cfs-file" collection="images"}}
  </div>
  <div class="textField" style="margin-left:20px;">
    {{> afQuickField name="primary_color"}}
  </div>
</fieldset>
<button type="submit" class="btn btn-primary">Add a School</button>
</template>
{{/autoForm}}

学校集合 js

Schools = new Mongo.Collection("Schools");


//Defining the schema
Schools.attachSchema(new SimpleSchema({
 name: {
 type:String,
 label: "Name",
 max:200
}
user_id:{
 type: String,
 autoform: {
  type: "hidden",
  label: false
 },
 autoValue: function(){
 if (this.isInsert) {
        return Meteor.userId();
    } else if (this.isUpsert) {
        return {$setOnInsert: Meteor.userId()};
    } else {
        this.unset();
    }
  },
denyUpdate:true
},
image: {
 type: String,
 label: "Logo",
 autoform: {
   afFieldInput: {
     type: "cfs-file",
     collection: "images"
   }
 }
},
 ...

common.js

FS.debug = true; // enable CFS debug logging

// Image collection methods
Images = new FS.Collection("images", {
stores: [new FS.Store.FileSystem("images")]
});

Images.allow({
 download: function () {
 return true;
},
fetch: null
});
4

0 回答 0