gpt4 book ai didi

azure - StorageSharedKeyCredential 不是构造函数 : vue. js + azure-blob 存储

转载 作者:行者123 更新时间:2023-12-02 07:23:05 25 4
gpt4 key购买 nike

当尝试连接到 azure-blob-storage 并尝试包装连接信息并使用 [StorageSharedKEyCredential] 时,出现以下错误:

StorageSharedKeyCredential is not a constructor

我正在使用 Vue.js。

也有类似的问题,就是版本不同,所以查了文档和版本。
(使用版本:“@azure/storage-blob”:“^12.1.1”)

如何使用 StorageSharedKEyCredential?
最后,我希望能够访问 Azure Blob 存储。
请告诉我。

==============================
代码是这样的。

const { StorageSharedKeyCredential,BlobServiceClient } = require("@azure/storage-blob");

mounted: function () {
this.init()
},
methods: {
init: function () {
this.accessBlob()
.then(() => console.log('Done'))
.catch((ex) => console.log('catch:', ex.message));
},
accessBlob: async function(){
const config = require("./config/config.json");
const ACCOUNT_NAME = config.storageAccount;
const ACCOUNT_ACCESS_KEY = config.storageAccessKey;

// Create the BlobServiceClient object which will be used to create a container client
const credentials = new StorageSharedKeyCredential(ACCOUNT_NAME, ACCOUNT_ACCESS_KEY);

const blobServiceClient = new BlobServiceClient(
`https://${ACCOUNT_NAME}.blob.core.windows.net`,
credentials
);
let i = 1;
for await (const container of blobServiceClient.listContainers()) {
console.log(`Container ${i++}: ${container.name}`);
}
}
}

==============================

(引用:SharedKeyCredential is not a constructor - Azure Blob Storage + Nodejs)

最佳答案

您需要使用共享访问签名 (SAS) 或 OAuth token 进行身份验证,因为 SharedKeyCredential 仅在运行时可用。

关于azure - StorageSharedKeyCredential 不是构造函数 : vue. js + azure-blob 存储,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/61314949/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com