我使用了一个azure函数来使用jimp生成缩略图。我遇到的挑战是azure容器上的内容类型最终是application/octet-stream而不是image/jpeg。如何解决这个问题?
下面是代码:
var Jimp = require("jimp");
module.exports = (context, myBlob) => {
// Read image with Jimp
Jimp.read(myBlob).then((image) => {
// Manipulate image
image
.resize(200, 200)
.getBuffer( Jimp.MIME_JPEG, (error, stream) => {
// Check for errors
if (error) {
context.log(`There was an error processing the image.`);
context.done(error);
}
else {
context.log(`Successfully processed the image`);
context.bindingData.properties = {contentType: Jimp.MIME_JPEG}
// Bind the stream to the output binding to create a new blob
context.done(null, stream);
}
});
});
};发布于 2018-06-17 18:51:07
不幸的是,Blob输出绑定目前不支持设置内容类型。请参阅Blob bindings can't set ContentType and other properties以跟踪进度。
目前,您必须退回到直接使用Storage SDK。有关示例,请参阅同一问题中的this comment。
如果可以选择C#,请选中this example。
https://stackoverflow.com/questions/50895611
复制相似问题