成功将base64映像保存到Azure Blob存储,但blob映像始终损坏/小的白色框
我有一个图像转换为base64我想上传到我的azure色blob存储使用createBlockBlobFromText。
self.blobServer.createBlockBlobFromText(containerName, fileName, baseStrChars, { contentSettings: { contentType: 'image/jpeg' } }, function(error, result, response) { if (error) { console.log(error); } console.log("result", result); console.log("response", response); });
我新的JPEG图像出现在BLOB存储容器,但是当我去blob图像的URL我总是得到这个 。
我的容器的访问策略设置为容器,我粘贴我的base64string到base64图像转换器,并出现正确的图像。 这个问题似乎是我创buildblob而不是base64string的方式。
我感到困惑,为什么整个stream程似乎工作,但仍然是图像被打破,当我去的url。 有任何想法吗 ?
通过浏览器中的Url直接访问图像需要二进制内容。 您可以将base64编码的string转换为node.js后端的二进制缓冲区,然后将缓冲区string上传到Azure存储。
请尝试下面的代码片段:
var rawdata = 'data:image/jpeg;base64,iVBORw0KGgoAAAANSUhEUgAAAAUAAAAFCAYAAACNbyblAAAAHElEQVQI12P4//8/w38GIAXDIBKE0DHxgljNBAAO9TXL0Y4OHwAAAABJRU5ErkJggg=='; var matches = rawdata.match(/^data:([A-Za-z-+\/]+);base64,(.+)$/); var type = matches[1]; var buffer = new Buffer(matches[2], 'base64'); blobsrv.createBlockBlobFromText('mycontainer','profile-pic-123.jpg', buffer, {contentType:type}, function(error, result, response) { if (error) { console.log(error); }else{ console.log(result) } });
- 使用Bot FrameworkloggingNode.js-Azure应用程序
- 如何准备我的Azure函数的代码
- 是否有可能从Linux发布Node.js应用程序到Azure?
- 如何在使用Kudu将node.js应用程序部署到Azure时debuggingdeploy.sh?
- Azure部署错误errno 47
- 无法升级Azure App Service中的Node.js版本
- 最小的azure node.jsconfiguration服务.js文件作为纯文本,而不是处理它们
- Node.js Azure Web App Windows 500.1001错误
- 部署到云时,无法将实体添加到node.js中的azure色存储表中?