[英]CollectionFS and Meteor: how to join uploaded files with existing collection
[英]Meteor CollectionFS Collection is Undefined?
我正在嘗試使用CollectionFS和GridFS將一些圖像上傳到我的應用程序並將其提供回來。
我有以下定義:
ImageStore.js:
var imageStore = new FS.Store.GridFS("images", {
mongoUrl: 'mongodb://127.0.0.1:27017/test/',
transformWrite: myTransformWriteFunction,
transformRead: myTransformReadFunction,
maxTries: 1,
chunkSize: 1024*1024
});
EventImages = new FS.Collection("images", {
stores: [imageStore]
});
ImageStorePub.js:
Meteor.publish("EventImages", function() {
return EventImages.find();
});
ImageUploadHandler.js:
if (Meteor.isServer) {
EventImages.allow({
'insert': function() {
// add custom authentication code here
return true;
}
});
}
鍵入所有這些內容后,我嘗試將它們全部包裝在if(Meteor.isServer){...}
盡管它們已經在我的服務器文件夾中,但由於錯誤ReferenceError: EventImages is not defined at server/route handlers/ImageUploadHandler.js:2:1
,我的應用仍然崩潰ReferenceError: EventImages is not defined at server/route handlers/ImageUploadHandler.js:2:1
我在客戶端和服務器上均未分配變量時犯了一個錯誤。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.