TypeError 无法在 typeScript Azure blob 上传中设置未定义的属性“大小”

问题描述

我正在尝试将文件从本地路径上传到 azure blob 存储。下面是代码上传时出现错误,如 TypeError cannot set property 'size of' undefined

使用 SAS 令牌成功连接到 Azure Blob 存储(从控制台观察),但在内部获取错误获取文件大小。你能否在这里提出任何建议来解决这个问题。 注意:使用 StorageSharedKeyCredential,与 Azure 本身的连接未成功,显示存储共享密钥凭据不是构造函数

enter image description here

const {
    StorageSharedKeyCredential,BlobServiceClient
    } = require('@azure/storage-blob');
const path = require("path");
const localFilePath = "G:/test/download2.jpg";

const STORAGE_ACCOUNT_NAME = "***********";
const containerName = "container1";
const sas = "******************";

const blobServiceClient = new AzureAPI.BlobServiceClient(`https://${STORAGE_ACCOUNT_NAME}.blob.core.windows.net${sas}`);
const containerClient = blobServiceClient.getContainerClient(containerName);

const fileName = path.basename(localFilePath);
const blobClient = containerClient.getBlobClient(fileName);
const blockBlobClient = blobClient.getBlockBlobClient();
blockBlobClient.uploadFile(localFilePath)

;

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)