2
votes

I'm trying to get autoform-file working (https://github.com/yogiben/meteor-autoform-file), but it doesn't seem to be doing anything at all.

As per the quick start, I've done the following:

1) Defined a collection with the right permissions:

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) Published my collection:

Meteor.publish('images', function () { 
    Meteor.Images.find({});
});

3) Updated my router to wait for the subscription:

Router.route('/test', {
    waitOn: function () {
        Meteor.subscribe('images');
    },
    action: function () {
        this.render('test', {to: 'main'});
    }
}); 

4) Defined a schema:

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) Used a quickform in my 'test' template:

{{> quickForm collection="Test" type="insert"}}

The quickform displays in the template with a button saying 'Upload at file' as defined in the schema. When I click the button I can browse and click a file in my local filesystem. However, when I click the submit button in the quickform, I get an error saying "User img is required".

This is baffling for me. I've followed the steps perfectly (I think) in the quick start and yet it's not doing anything at all... Does anyone have any idea where I'm going wrong?

1

1 Answers

1
votes

Turns out the cfs:filesystem package doesn't work with autoform-file. I changed to GridFS and it's working fine now.