title: Azure Blob Node.js download blob files
body: <p>I have node.js Application with Frontend in Angular, I need to upload and download files to Azure blob/azure storage</p>
  
  <p>I have followed instructions given here: <a href="https://github.com/Azure/azure-sdk-for-js/blob/master/sdk/storage/storage-blob/samples/typescript/src/basic.ts" rel="nofollow noreferrer">https://github.com/Azure/azure-sdk-for-js/blob/master/sdk/storage/storage-blob/samples/typescript/src/basic.ts</a></p>
  
  <p>now when I download it reads the image or file in readable stream, how can I download the file from azure blob</p>
  
  <p>below is my code which list the blobs reads to readable stream</p>
  
  <pre><code>const { BlobServiceClient, StorageSharedKeyCredential, BlobDownloadResponseModel } = require('@azure/storage-blob');
  
  const uuidv1 = require('uuid/v1');
  
  async ListBlob(req,res){
      const blobServiceClient = await BlobServiceClient.fromConnectionString(this.AZURE_STORAGE_CONNECTION_STRING);
      const container = blobServiceClient.getContainerClient('mycontainer');
      const containerClient = await blobServiceClient.getContainerClient(container.containerName);
      let temp = Array();
      // List the blob(s) in the container.
      for await (const blob of containerClient.listBlobsFlat()) {
          temp.push(blob.name);
      }
      const blockBlobClient = containerClient.getBlockBlobClient(temp[2]);
      const downloadBlockBlobResponse = await blockBlobClient.download(0);
      let result = await this.streamToString(downloadBlockBlobResponse.readableStreamBody!);
      res.send(result);
  
  }
  
  async streamToString(readableStream) {
    return new Promise((resolve, reject) =&gt; {
      const chunks = [];
      readableStream.on("data", (data) =&gt; {
        chunks.push(data.toString());
      });
      readableStream.on("end", () =&gt; {
        resolve(chunks.join(""));
      });
      readableStream.on("error", reject);
    });
  }
  </code></pre>