azure createBlockBlobFromLocalFile没有显示这样的文件或目录 [英] azure createBlockBlobFromLocalFile shows no such file or directory

查看:175
本文介绍了azure createBlockBlobFromLocalFile没有显示这样的文件或目录的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用azure-storage函数createBlockBlobFromLocalFile()上传文件.但是当我上传文件时,出现了

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

{错误:ENOENT:没有这样的文件或目录,stat'D:\ path \ task1.txt'
errno:-4058,代码:'ENOENT',syscall:'stat',路径: 'D:\ path \ task1.txt'}

{ 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);
        }
      }); 

推荐答案

我重新使用了上面的示例代码,并对blobUri进行了一些修改,并添加了sasKey值,并且能够将新的块blob上传到我的存储帐户blob容器中

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.

请确保上面的JavaScript代码文件与要上传的文本文件位于同一路径,即

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:

天蓝色存储节点模块版本: 2.8.0

Node.js 版本: 8.9.4

npm 版本: 5.6.0

希望这会有所帮助!

这篇关于azure createBlockBlobFromLocalFile没有显示这样的文件或目录的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆