Error: FS.Collection cannot remove file belongs to: "images" not: "cfs.images.filerecord"

Error: FS.Collection cannot remove file belongs to: "images" not: "cfs.images.filerecord"

我在尝试删除文件时遇到错误:FS.Collection 无法删除文件属于:"images" 不:"cfs.images.filerecord"。 我找不到太多关于删除文档和此处文件的信息。

Images = new FS.Collection("images", {
    stores: [
      new FS.Store.FileSystem("images"),
      new FS.Store.FileSystem("thumbs", {
        beforeWrite: function(fileObj) {
          // We return an object, which will change the
          // filename extension and type for this store only.
          return {
            extension: 'png',
            type: 'image/png'
          };
        },
        transformWrite: function(fileObj, readStream, writeStream) {
          // Transform the image into a 10x10px PNG thumbnail
          gm(readStream).resize(60).stream('PNG').pipe(writeStream);
          // The new file size will be automatically detected and set for this store
        }
      })
    ],
    filter: {
      allow: {
        contentTypes: ['image/*'] //allow only images in this FS.Collection
      }
    }
});

Images.allow({
    insert: function(userId, file) { return userId && file.owner === userId; },
    update: function(userId, files, fields, modifier) {
        return _.all(files, function (file) {
            return (userId == file.owner);
        });  //EO iterate through files
    },
    remove: function(userId, files) { return userId && file.owner === userId; },
    download:function(){return true;}
});

完整的堆栈跟踪如下:

I20150123-02:46:49.798(5)? Exception while invoking method 'deleteImage' Error: FS.Collection cannot remove file belongs to: "images" not: "cfs.images.filerecord"
I20150123-02:46:49.798(5)?     at EventEmitter.FS.Collection.remove (packages/cfs:collection/api.common.js:136:1)
I20150123-02:46:49.798(5)?     at [object Object].Meteor.methods.deleteImage (app/lib/collections/images.js:40:10)
I20150123-02:46:49.798(5)?     at maybeAuditArgumentChecks (packages/ddp/livedata_server.js:1599:1)
I20150123-02:46:49.798(5)?     at packages/ddp/livedata_server.js:648:1
I20150123-02:46:49.799(5)?     at [object Object]._.extend.withValue (packages/meteor/dynamics_nodejs.js:56:1)
I20150123-02:46:49.799(5)?     at packages/ddp/livedata_server.js:647:1
I20150123-02:46:49.799(5)?     at [object Object]._.extend.withValue (packages/meteor/dynamics_nodejs.js:56:1)
I20150123-02:46:49.799(5)?     at [object Object]._.extend.protocol_handlers.method (packages/ddp/livedata_server.js:646:1)
I20150123-02:46:49.799(5)?     at packages/ddp/livedata_server.js:546:1

可能是什么问题?

谢谢!

如果您已经有一个 allow rule,则 不需要 使用 Meteor call

试试这 2 个解决方案。

Template.example.events({
  'click #removeImage':function(event){
      event.preventDefault(); 
      var mensaje = confirm('are you sure you want to delete this image?');
     if(mensaje === true){
       this.remove();
     } else {
      console.log("Nothing was deleted");
     }
  }
})

或者这个。

Template.example.events({
      'click #removeImage':function(event){
          event.preventDefault(); 
          var mensaje = confirm('are you sure you want to delete this image?');
         if(mensaje === true){
           Images.remove({_id:this._id},function(err,result){
                  if(!err){
                   console.log("Remove success");
                   }
              })
         } else {
          console.log("Nothing was deleted");
         }
      }
    })

两者都应该有效,或者最近在控制台上抛出拒绝访问。