问题
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);
}
});
回答1:
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.
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!
来源:https://stackoverflow.com/questions/49050378/azure-createblockblobfromlocalfile-shows-no-such-file-or-directory