2014-09-26 119 views
0

我正在試圖遵循Meteor CollectionFS指令來獲得一個簡單的文件上傳工作。我已經添加了以下內容:客戶端文件上傳使用cfs文件系統

在model.js

Images = new FS.Collection("images", { 
    stores: [new FS.Store.FileSystem("images", {path: "~/uploads"})] 
}); 

在Server.js我發佈此收集和client.js我訂閱了它。

在模板時,我得到的文件,並在集合中插入如下:

Images.insert(files[0], function (err, fileObj) { 
    //Inserted new doc with ID fileObj._id, and kicked off the data upload using HTTP 
    if(err) console.log(err); 
}); 

但是,這將引發一個錯誤 - 500 Meteor.error,內部服務器錯誤。 有人知道爲什麼會發生這種情況嗎?

回答

1

得到它的工作:

需要添加Images.allow規則返回true或false。

Images.allow({ 
    insert: function(userId, doc) { 
    return (userId && doc.metadata.owner === userId); 
    }, 
    update: function(userId, doc, fieldNames, modifier) { 
    return (userId && doc.metadata.owner === userId); 
    }, 
    remove: function(userId, doc) { 
    return false; 
    } 
});