<small id='gdohn'></small><noframes id='gdohn'>

      <tfoot id='gdohn'></tfoot>
        <bdo id='gdohn'></bdo><ul id='gdohn'></ul>
    1. <legend id='gdohn'><style id='gdohn'><dir id='gdohn'><q id='gdohn'></q></dir></style></legend>

        <i id='gdohn'><tr id='gdohn'><dt id='gdohn'><q id='gdohn'><span id='gdohn'><b id='gdohn'><form id='gdohn'><ins id='gdohn'></ins><ul id='gdohn'></ul><sub id='gdohn'></sub></form><legend id='gdohn'></legend><bdo id='gdohn'><pre id='gdohn'><center id='gdohn'></center></pre></bdo></b><th id='gdohn'></th></span></q></dt></tr></i><div id='gdohn'><tfoot id='gdohn'></tfoot><dl id='gdohn'><fieldset id='gdohn'></fieldset></dl></div>

        如何在不本地保存的情况下将 base64 数据传输到可读的图像流中

        时间:2023-09-30

        <small id='3xrfi'></small><noframes id='3xrfi'>

          <tbody id='3xrfi'></tbody>
        <i id='3xrfi'><tr id='3xrfi'><dt id='3xrfi'><q id='3xrfi'><span id='3xrfi'><b id='3xrfi'><form id='3xrfi'><ins id='3xrfi'></ins><ul id='3xrfi'></ul><sub id='3xrfi'></sub></form><legend id='3xrfi'></legend><bdo id='3xrfi'><pre id='3xrfi'><center id='3xrfi'></center></pre></bdo></b><th id='3xrfi'></th></span></q></dt></tr></i><div id='3xrfi'><tfoot id='3xrfi'></tfoot><dl id='3xrfi'><fieldset id='3xrfi'></fieldset></dl></div>

            <bdo id='3xrfi'></bdo><ul id='3xrfi'></ul>
                <legend id='3xrfi'><style id='3xrfi'><dir id='3xrfi'><q id='3xrfi'></q></dir></style></legend>

                1. <tfoot id='3xrfi'></tfoot>

                  本文介绍了如何在不本地保存的情况下将 base64 数据传输到可读的图像流中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  我正在使用 Node.js 使用 Microsoft Bot Framework(托管在 Azure 上),并且无法在本地保存文件.我有 base64 格式的图像数据,我需要将这些数据传输到图像文件的可读流中,我可以使用他们的 Blob Storage API(接收流)将其泵入 Azure.

                  I'm working with the Microsoft Bot Framework (hosting on Azure) using Node.js, and saving files locally isn't an option. I have image data in base64 format, and I need to transfer that data into a readable stream of an image file that I can pump into Azure using their Blob Storage API (which takes a stream).

                              var base64ImageData; //my base64 image
                  
                              //Create myStream here
                  
                              //Then send to Azure
                              blobService.createBlockBlobFromStream('mycontainer', 
                              nameForBlob, myStream, fileSize, 
                              function (error, result, response){ 
                                  if(!error)
                                      console.log(response);
                                  else
                                      console.log(error)
                              });
                  

                  任何帮助将不胜感激.如果不将 jpg 保存到我的磁盘上,我不知道如何解码 base64 并从中生成流.

                  Any help would be appreciated. I can't figure out how to decode the base64 and make a stream out of it without saving a jpg onto my disk.

                  推荐答案

                  请尝试以下方法:

                  var azureStorage = require('azure-storage');
                  var streamifier = require('streamifier');
                  
                  var base64String = 'iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAAJcEhZcwAADsMAAA7DAcdvqGQAAAEiSURBVDhPxZIhT0NBEITnoBKBrEQgEUhISEiqKiFUYJDI/gBEc8VVY5AYHKKGBIEAVBFN+A8EUVFZUdGk/XbvGtqmpS8ImGTu5vbd7N3tPv0Pog5gzeSGB4oiqgSbCnphNbRQsKEQorbY/YCqaqwrXatl4WIJosrsfELtw3vucOFxsP4J6eRnlJnfOf3S4xk/J0hmO3kPfmE+5er+9ilSAqtoU203TGEFC7pDHcFBNvf82wxSgqAzxhPmDsbdHLtl9FZhbmDuul5AKmLUNuoDtQMH8BGeQ0OXBIckGOX1HL67ELlq6m8pBRyjbF56umEzz9KbPnXM9qBKjhhuMFsdVmKxC/ZzvCbpVW9kvRLzCeydY/9J+sx11laPXyB63/8C0gQlpj3Fc3O2WAAAAABJRU5ErkJggg==';
                  var blobService = azureStorage.createBlobService('account-name', 
                      'account-key');
                  var buffer = Buffer.from(base64String, 'base64');
                  var stream = streamifier.createReadStream(buffer);
                  blobService.createBlockBlobFromStream('container-name', 'checked.png', stream, buffer.byteLength, function(error, response) {
                          if (error) {
                              console.log('Error!');
                              console.log(error);
                          } else {
                              console.log('Blob uploaded successfully!');
                              console.log(response);
                          }
                      });
                  

                  我必须安装 streamifier 节点包来转换缓冲区流式传输.

                  I had to install streamifier node package to convert buffer to stream.

                  这篇关于如何在不本地保存的情况下将 base64 数据传输到可读的图像流中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  上一篇:Angular ui 路由器 ui-sref-active 在父级上 下一篇:将 PNG Base-64 字符串转换为 TIFF Base-64 字符串

                  相关文章

                2. <tfoot id='ZlYLS'></tfoot>

                  <small id='ZlYLS'></small><noframes id='ZlYLS'>

                      <bdo id='ZlYLS'></bdo><ul id='ZlYLS'></ul>
                  1. <legend id='ZlYLS'><style id='ZlYLS'><dir id='ZlYLS'><q id='ZlYLS'></q></dir></style></legend>
                    <i id='ZlYLS'><tr id='ZlYLS'><dt id='ZlYLS'><q id='ZlYLS'><span id='ZlYLS'><b id='ZlYLS'><form id='ZlYLS'><ins id='ZlYLS'></ins><ul id='ZlYLS'></ul><sub id='ZlYLS'></sub></form><legend id='ZlYLS'></legend><bdo id='ZlYLS'><pre id='ZlYLS'><center id='ZlYLS'></center></pre></bdo></b><th id='ZlYLS'></th></span></q></dt></tr></i><div id='ZlYLS'><tfoot id='ZlYLS'></tfoot><dl id='ZlYLS'><fieldset id='ZlYLS'></fieldset></dl></div>