如何使用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到Azure事件中心的HTTPS请求的ECONNRESET错误
- 在Azure上部署MEAN + Webpack
- 导入发布设置文件时出现w / Azure CLI错误
- 如何正常停止为Nodejs编写的Azure WebJob
- package.json失败,出现错误Windows_NT 6.2.9200蔚蓝
- Windows Azure中的node.js应用程序部署
- 在Windows Azure模拟器中运行的Node.js Web应用程序
- 使用Azure移动服务计划任务访问Azure服务pipe理REST API
- 如何在Azure AD上使用passport.js和OpenID Connect策略