如何使用Node.js将Windows Azure Blobstream式传输到客户端?
我想直接发送一个Windows Azure Blob(一个图像)到客户端; 我正在尝试这个:
blobService.getBlobToStream('images', req.url, res, function(err, blob) { if (!err) { res.writeHead(200, { 'Content-Type': blob.contentType }); } else { res.writeHead(200, { 'Content-Type': 'text/plain' }); res.end(err); } });
我正在尝试将Blobstream直接传递给响应stream; 应该这个工作吗? 在Firefox中,我收到一条消息:“图像无法显示,因为它包含错误”。 看着Firebug,图像的大小是0。
这对我来说似乎是很正常的(如果这有什么帮助的话):
var azure = require('azure'); var http = require('http'); http.createServer(function (req, res) { var blobService = azure.createBlobService("xxx", "yyy", "blob.core.windows.net").withFilter(new azure.ExponentialRetryPolicyFilter()); blobService.getBlobToStream('container', 'image.png', res, function(error){ if(!error){ res.writeHead(200, {'Content-Type': 'image/png'}); res.end(); } else { console.log('error'); console.log(error); res.end(); } }); }).listen(8080, "127.0.0.1");
更新
只是想通了。 req.url
将有一个前导斜杠(/)。 我猜的是不匹配你的图像文件名。
- 在Node.js Web应用程序中使用用户名和密码在Azure AD上进行身份validation
- 您无权查看Azure Ionic App的此目录或页面
- 稳定节点JS AMQP 1.0客户端(事件中心)
- 哪种azure色的服务,我应该select我的node.js应用程序?
- 在Windows Azure上使用MongoDB运行Node.js的问题
- 如何从服务器端注册设备到Azure通知中心(使用NodeJS sdk)?
- Node.js Azure Web App Windows 500.1001错误
- 如何在azure函数中触发失败http触发器,带有自定义错误响应
- Node.js服务器应用程序使用cors,express和google api在azure部署后不工作