我正在尝试使用Meteor-CollectionFS上传图片
Simlpe图片上传已成功上传。
但现在我也试着保留图像的缩略图。
但它会出现以下错误:
W20151211-14:38:38.240(5)? (STDERR) FS.Transform.createWriteStream transform function failed, Error:
I20151211-14:38:38.242(5)? Exception in queued task: Error: cfs:graphicsmagick could not find "graphicsMagick" or "imageMagick"
I20151211-14:38:38.242(5)? at gm (packages/cfs_graphicsmagick/packages/cfs_graphicsmagick.js:14:1)
I20151211-14:38:38.242(5)? at Object.createSquareThumb (model/model.js:9:1)
I20151211-14:38:38.242(5)? at packages/cfs_storage-adapter/packages/cfs_storage-adapter.js:355:1
I20151211-14:38:38.242(5)? at addPassThrough (packages/cfs_storage-adapter/packages/cfs_storage-adapter.js:421:1)
I20151211-14:38:38.243(5)? at [object Object].FS.Transform.createWriteStream (packages/cfs_storage-adapter/packages/cfs_storage-adapter.js:352:1)
I20151211-14:38:38.243(5)? at Object.self.adapter.createWriteStream (packages/cfs_storage-adapter/packages/cfs_storage-adapter.js:171:1)
I20151211-14:38:38.243(5)? at saveCopy (packages/cfs_worker/packages/cfs_worker.js:180:1)
I20151211-14:38:38.243(5)? at Object.fsCollection.files.find.observe.added (packages/cfs_worker/packages/cfs_worker.js:42:1)
I20151211-14:38:38.243(5)? at [object Object].observeChangesCallbacks.added (packages/minimongo/observe.js:153:1)
I20151211-14:38:38.243(5)? at self.applyChange.added (packages/minimongo/observe.js:53:1)
这是我的代码:
var createThumb = function(fileObj, readStream, writeStream) {
// Transform the image into a 10x10px thumbnail
gm(readStream, fileObj.name()).resize('10', '10').stream().pipe(writeStream);
};
Images = new FS.Collection("images", {
stores: [
new FS.Store.FileSystem("thumbs", { transformWrite: createThumb }, {path: "~/uploads/thumbs"}),
new FS.Store.FileSystem("images", {path: "~/uploads"}),
],
filter: {
allow: {
contentTypes: ['image/*'] //allow only images in this FS.Collection
}
}
});
我还添加了以下包装:
meteor add cfs:graphicsmagick
那么我在这里失踪的是什么?
答案 0 :(得分:1)
安装图形魔法。 包只是gm的包装器,你必须安装它。
我不记得确切的界面,但我认为Fs集合只接受一个对象,所以改变:
new FS.Store.FileSystem("thumbs", { transformWrite: createThumb }, {path: "~/uploads/thumbs"})
在:
new FS.Store.FileSystem("thumbs", { transformWrite: createThumb , path: "~/uploads/thumbs"})