Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/node.js/34.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
在Express()中呈现node.js中的图像(Azure移动服务)_Node.js_Azure_Express_Azure Mobile Services - Fatal编程技术网

在Express()中呈现node.js中的图像(Azure移动服务)

在Express()中呈现node.js中的图像(Azure移动服务),node.js,azure,express,azure-mobile-services,Node.js,Azure,Express,Azure Mobile Services,我尝试使用Azure移动服务的Express渲染图像。 我从SQL数据库获取图像,没什么大不了的 但是当我试图渲染我的图像时,它并没有像预期的那样工作 这是我的密码: exports.getImage = function (request, response) { console.log('Getting image param : ' + request.params.imageId); var imageId = request.params.imageId; var tableIma

我尝试使用Azure移动服务的Express渲染图像。 我从SQL数据库获取图像,没什么大不了的

但是当我试图渲染我的图像时,它并没有像预期的那样工作

这是我的密码:

exports.getImage = function (request, response) {

console.log('Getting image param : ' + request.params.imageId);

var imageId = request.params.imageId;
var tableImage = request.service.tables.getTable('Images');

tableImage
    .where({ id: imageId })
    .read({
        success: function (results) {
            var img = results[0];

            // var base64Image = img.imageblob.toString('base64');
            // var decodedImage = new Buffer(base64Image, 'base64');

            console.log('Image Name : ' + img.name + ' ' + img.imageformat);
            var decodedImageBinary = new Buffer(img.imageblob, 'binary');
            var contentType = 'image/' + img.imageformat;

            response.set('Content-Type', contentType);
            response.send(decodedImageBinary);


        },
        error: function (err) {
            console.error(err);
        }
    });
}

不起作用怎么办?您是否有任何错误?否:)结果如下:使用Fiddler,您可以看到(至少对我来说)一切似乎都正常
response.end(decodedImageBinary,'binary')Thx@BenFortune为您的时间:)我已经测试了您的解决方案,结果完全相同。