0

My Requirement is to copy, list of the files from client(browser) to azure blob using SAS URL. So I am using azure-sdk-for-node, but its look like its not working for me. Can someone recommend any solution or any other library ?.

var azure = require('azure-storage');
var blobSvc = azure.createBlobServiceWithSas('https://XXXXXXXXXX', 'XXXXXXXXX"');

blobSvc.createBlockBlobFromBrowserFile('testmigration', 'taskblob', 'abc.txt', function (error, result, response){
       if (!error) {
            console.log('file uploaded failed', error);
        } else {
            console.log('file uploaded success');
        }})

ERROR : blobSvc.createBlockBlobFromBrowserFile is not a function

Rahul Rai
  • 205
  • 1
  • 12
  • Is the code you mentioned above is the actual code you're using? Shouldn't you be using it something like this: `blobSvc.createBlockBlobFromBrowserFile('testmigration', 'taskblob', 'abc.txt', function (error, result, response) {//callback handling code here});`? – Gaurav Mantri Feb 22 '18 at 13:28
  • @GauravMantri Your are correct I haven't added the below codes. but what you have mentioned, my code is like that only. Updated my question – Rahul Rai Feb 22 '18 at 13:38
  • And just to confirm, you're running this code in the browser only and not a pure node application? Also, where you used `abc.txt`, it should be an object of type `File` and not simple string. – Gaurav Mantri Feb 22 '18 at 13:48
  • @GauravMantri I am using node js application. and yes that abc.txt is wrong it should be the File that is selected by the user. – Rahul Rai Feb 22 '18 at 14:25
  • 1
    I don't think you can use this function in a node application. This has to be used in a client side JavaScript only. For node, the correct method is `createBlockBlobFromLocalFile`. – Gaurav Mantri Feb 22 '18 at 14:37
  • @GauravMantri Thanks Gaurav, I also have come to same conclusion. thanks again – Rahul Rai Feb 22 '18 at 14:55

0 Answers0