I have a service written in node js. It's job is to connect to azure storage download a file and returning it as base64.
here's what I did so far:
` var azure = require('azure-storage');
const fs = require('fs');
var fileService = azure.createFileService('microsoftdata');
var test = await fileService.getFileToStream('sharename', '', filename, fs.createWriteStream(filename), async function (error, result, response) {
  if (!error) {
    console.log('result ' + JSON.stringify(result, null, 4));
    var bitmap = await fs.readFileSync(filename);
    return bitmap.toString('base64');
    // var str = getFileAsBase64(filename);
    // console.log('str - ' + str);
    // return str;
    // file downloaded
  }
  else {
    console.log('error - ' + JSON.stringify(error, null, 4));
  }
});
console.log('test - ' + test);`
What's happening now is : downloading a file -> returning data of file in var 'test' -> finished download entering the callback and returning base64 to nowhere.
What I want to achieve is : downloading a file -> waiting for finish -> finished and enter callback -> return base64 to test or another var in his scope.
Thanks.
 
     
     
    