看看docs,看起來像它在服務器端可用的gm範圍,所以沒有問題M}這裏,你具有的console.log,漂亮發現
現在你可以使用,在fsCollection這樣
Images = new FS.Collection("images", {
stores: [
new FS.Store.FileSystem("images"),
new FS.Store.FileSystem("thumbs", {
transformWrite: function(fileObj, readStream, writeStream) {
// Transform the image into a 10x10px thumbnail
gm(readStream, fileObj.name()).resize('10', '10').stream().pipe(writeStream);
}
})
],
filter: {
allow: {
contentTypes: ['image/*'] //allow only images in this FS.Collection
}
}
});
記得gm
它只是在服務器上可用,所以使用它/server
或使用在if(isServer)
試試這個
if (Meteor.isServer) {
if (gm.isAvailable) {
console.log("gm is available and this console.log was printed from my own code");
}
}
告訴我,如果作品
更新答案
如果您既是服務器/客戶端上宣佈FS.collection我建議你上/lib/collection.js
聲明收集這樣
//collections.js
Adopcion = new FS.Collection("Adopcion", {
stores: [
new FS.Store.FileSystem("images"),
new FS.Store.FileSystem("thumbs", {
transformWrite: function(fileObj, readStream, writeStream) {
// Transform the image into a 10x10px thumbnail
gm(readStream, fileObj.name()).resize('10', '10').stream().pipe(writeStream);
}
})
]
});
,並在同一個文件進行訂閱 // collection.js //訂閱 if(Meteor.isClient)Meteor.subscribe('Adopcion'); } 而現在/server/publish.js
你只會使發佈功能
//Publish methods
Meteor.publish('Adopcion', function(){
return Adopcion.find();
});
由於沒有必要的Meteor.methods({})
的第一件事情流星將加載其集合,他們將提供包括客戶端/服務器
上
看一看,並告訴我是否適合你
謝謝Etjana,你是對的。我不知道gm只能在服務器上使用。我剛剛開始,所以我還不知道如何通過服務器實現gm。將不得不查看它。這是[methods](http://meteortips.com/book/methods/)我需要理解 - 對吧? – Kai
檢查答案的更新,並採取嘗試,希望它的工作原理:D – Ethaan
一切似乎工作正常,啓動時沒有錯誤。但後來我得到重複錯誤: GET http:// localhost:3000/sockjs/info?cb = 3lkaaq_h3u 503(服務不可用)sockjs-0.3.4.js:854 AbstractXHRObject._startsockjs-0.3.4.js:888 (匿名函數) 生成的縮略圖也是空的(零kb) – Kai