title: Trying to upload zip file to azure storage via node js
body: <p>Trying to upload file to azure storage blob using nodejs but facing promise  issue. below is my code facing issue while uploading zip file to azure blob storage need to convert this code to callback function or .then function</p>
  <pre><code>var re = /\.zip/;
  
  fs.readdir(&quot;/tmp/&quot;, function(err, files) {
      if (err) {
          console.log( &quot;Could not list the directory.&quot;, err)
          process.exit( 1 )
      }
      console.log(&quot;files&quot;,files)
      
      var matches = files.filter( function(text) { return re.test(text) } )
      console.log(&quot;These are the files you have&quot;, matches)
      var numFiles = matches.length
      console.log(numFiles);
  
      if ( numFiles ) {
          // Read in the file, convert it to base64, store to S3
  
          for(let i = 0; i &lt; numFiles; i++ ) {
      
            uploadFileToBlob(matches[i])
            .then((result: any) =&gt; {
                console.log('result');
                console.log(result);
              })
              .catch((error: any) =&gt; {
                console.log(error);
              });
          }
      }
  })
  const uploadFileToBlob = async (file: any) =&gt; {
            const { AbortController } = require(&quot;@azure/abort-controller&quot;);
            const { AnonymousCredential, BlobServiceClient, newPipeline } = require(&quot;@azure/storage-blob&quot;);
            const account = 'string';
            const accountSas = &quot;sastoken&quot;;
            const localFilePath = file;
            const pipeline = newPipeline(new AnonymousCredential(), {
              // httpClient: MyHTTPClient, // A customized HTTP client implementing IHttpClient interface
              retryOptions: { maxTries: 4 }, // Retry options
              userAgentOptions: { userAgentPrefix: &quot;AdvancedSample V1.0.0&quot; }, // Customized telemetry string
              keepAliveOptions: {
                // Keep alive is enabled by default, disable keep alive by setting false
                enable: false
              }
            });
            const blobServiceClient = new BlobServiceClient(
              `https://${account}.blob.core.windows.net${accountSas}`,
              pipeline
            );
            const containerName = 'quickstart';
            const containerClient = blobServiceClient.getContainerClient(containerName);
            const blobName = file;
            const blockBlobClient = containerClient.getBlockBlobClient(blobName);
            console.log(&quot;blockBlobClient&quot;,blockBlobClient);
            try {
                    const result =await  blockBlobClient.uploadFile(localFilePath, {
                      blockSize: 4 * 1024 * 1024, // 4MB block size
                      concurrency: 20, // 20 concurrency
                      onProgress: (ev: any) =&gt; console.log(ev)
                    });
                    console.log(&quot;uploadFile succeeds&quot;);
                    return result;
                  } catch (err) {
                    console.log(
                      `uploadFile failed, requestId - ${err.details.requestId}, statusCode - ${err.statusCode}, errorCode - ${err.details.errorCode}`
                    );
                    throw err;
                  }
  }
  </code></pre>
  <p>getting output</p>
  <pre><code>Promise { &lt;pending&gt; }
  </code></pre>
  <p>I tried to write code in callback function or .then function but getting same error and same code is working in local machine</p>