0
我正在嘗試創建正在上傳到我的Amazon S3商店的圖像的縮略圖。圖像上傳本身工作正常,但由於某些原因,gm(readStream,fileObj.name()).ize('50','50')。stream()。pipe(writeStream)調用永遠不會發生,因爲gm .isAvailable返回undefined。但是,當我直接從流星殼環境中調用它時,我會得到「真實」的結果。我究竟做錯了什麼?GraphicsMagick未被調用
if (Meteor.isServer) {
var imageStore = new FS.Store.S3("images", {
region: "eu-west-1",
accessKeyId: (Meteor.isServer && !process.env.AWS_ACCESS_KEY_ID ? Meteor.settings.AWSAccessKeyId : null),
secretAccessKey: (Meteor.isServer && !process.env.AWS_SECRET_ACCESS_KEY ? Meteor.settings.AWSSecretAccessKey : null),
bucket: Meteor.isServer && process.env.AWS_S3_BUCKET || Meteor.settings.AWSBucket,
folder: "images"
});
var thumbStore = new FS.Store.S3("thumbnails", {
region: "eu-west-1",
accessKeyId: (Meteor.isServer && !process.env.AWS_ACCESS_KEY_ID ? Meteor.settings.AWSAccessKeyId : null),
secretAccessKey: (Meteor.isServer && !process.env.AWS_SECRET_ACCESS_KEY ? Meteor.settings.AWSSecretAccessKey : null),
bucket: Meteor.isServer && process.env.AWS_S3_BUCKET || Meteor.settings.AWSBucket,
folder: "thumbnails",
transformWrite: function(fileObj, readStream, writeStream) {
// transform image into 50 x 50 thumbnail
console.log("thumbnail transform");
console.log(gm.IsAvailable);
if (gm.IsAvailable) {
return gm(readStream, fileObj.name()).resize('50','50').stream().pipe(writeStream);
} else {
console.log("That didn't work");
}
}
});
Images = new FS.Collection("Images", {
stores: [
thumbStore,
imageStore
],
filter: {
allow: {
contentTypes: ['image/*']
}
}
});
}
// end server
if (Meteor.isClient) {
var imageStore = new FS.Store.S3("images");
var thumbStore = new FS.Store.S3("thumbnails");
Images = new FS.Collection("Images", {
stores: [
thumbStore,
imageStore
],
filter: {
allow: {
contentTypes: ['image/*']
}
}
});
}
// end client
當我開始我的應用程序或上傳圖片,我得到「縮略圖改造」,「不確定」和「那不工作」 ......
我在Win 10運行,安裝GraphicsMagick 1.3.21,我使用的是cfs:graphicsmagick軟件包。
有沒有人有任何想法?
用小寫'i'試試'gm.isAvailable'。 –
完全工作,感謝代碼審查,我現在感到愚蠢。 :-X – Achtel
@Brian Shamblen你想添加這個答案嗎? – Achtel