Set Thumbnail image Content-Type

∥☆過路亽.° 提交于 2019-12-04 18:51:08

EDIT:

Unfortunately the blob output binding for node does not support setting a content type. One option would be to drop the output binding and use the azure storage sdk natively in your node function which should give you the control you need.

If using an Http trigger and output binding:

An express-like 'res' object can be accessed via content.res, so instead of stream.set you'll want context.res.set / context.res.type. The stream object returned in the getBuffer callback is a buffer, not a stream, and has nothing to do with the http response.

One thing to note is that azure functions does not support returning of streams from node yet - you'll need to have the entire buffer (which, luckily, getBuffer appears to return!)

Here is a getBuffer callback:

function(err, buffer){
    if (err) {
        context.log("There was an error processing the image.");
        context.done(err);
    }
    else {
        context.log("Successfully processed the image");
        // set content type to Jimp.MIME_JPEG
        context.res.type(Jimp.MIME_JPEG)
        // send the raw response (don't apply any content negotiation)
        context.res.raw(buffer);
    }
});
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!