0

I am trying to uploading file using azure-storage function createBlockBlobFromLocalFile(). But when i upload the file i am getting error like

{ Error: ENOENT: no such file or directory, stat 'D:\path\task1.txt'
errno: -4058, code: 'ENOENT', syscall: 'stat', path: 'D:\path\task1.txt' }

But my file is inside the same path that i am using to run the file. So this means the uploading file and code both in same folder. Here is the code which i am trying to upload

var azureStorage = require('azure-storage');
var blobUri = "http://accountname.blob.core.windows.net";
var blobService = azureStorage.createBlobServiceWithSas(blobUri, sasKey).withFilter(new azureStorage.ExponentialRetryPolicyFilter());
blobService.createBlockBlobFromLocalFile('container', 'taskblob', 'task1.txt', function(error, result, response) {
        if (!error) {
            console.log("uplaoded");
        } else {
            console.log(error);
        }
      }); 
juvchan
  • 6,113
  • 2
  • 22
  • 35
skr07
  • 707
  • 1
  • 10
  • 36

1 Answers1

0

I reused your sample code above with slight modifications on the blobUri and added the sasKey value and I am able to upload a new block blob to my storage account blob container.

enter image description here

Please make sure that your JavaScript code file above is in the same path as your text file to be uploaded, i.e.

D:\path\yoursamplejs.js
D:\path\task1.txt

To run your script, do this:

D:\path\node yoursamplejs.js

You should expect to see the result output as: "uplaoded" in your case.

I have tested this working with:

azure-storage node module version: 2.8.0

Node.js version: 8.9.4

npm version: 5.6.0

Hope this helps!

juvchan
  • 6,113
  • 2
  • 22
  • 35
  • I am following the same folder structure. But still i am getting the error as `events.js:183 throw er; // Unhandled 'error' event ^ Error: ENOENT: no such file or directory, read` – skr07 Mar 02 '18 at 06:08
  • Also what are the versions of the above you are using? – juvchan Mar 02 '18 at 06:22
  • i am using node.js 8.9.1, npm 5.5.1 & azure-storage 2.8.0 – skr07 Mar 02 '18 at 06:28
  • How and where do you execute your script? – juvchan Mar 02 '18 at 06:38
  • I am running the script my local system. js file is available in `D:\path\upload.js` and uploading file is available in same path `D:\path\task1.txt`. I am running the code inside the path folder like `D:\path\node upload.js` – skr07 Mar 02 '18 at 06:40
  • What OS and version are you using? – juvchan Mar 02 '18 at 07:50
  • Let us [continue this discussion in chat](https://chat.stackoverflow.com/rooms/166078/discussion-between-juvchan-and-satheesh). – juvchan Mar 02 '18 at 07:53