【发布时间】:2020-03-27 08:55:49
【问题描述】:
我正在尝试删除我的 aucitonImages 容器中的图像,但是当我从邮递员执行该功能时,我得到 SharedKeyCredential is not a constructor 我一直在关注 documentation 并且我认为我已经设置了所有内容,但我没有'看不出我的代码与文档有什么不同。感谢您的帮助!
app.delete("/api/removeauctionimages", upload, async (req, res, next) => {
const { ContainerURL, ServiceURL, StorageURL, SharedKeyCredential } = require("@azure/storage-blob");
const credentials = new SharedKeyCredential(process.env.AZURE_STORAGE_ACCOUNT, process.env.AZURE_STORAGE_ACCESS_KEY);
const pipeline = StorageURL.newPipeline(credentials);
const serviceURL = new ServiceURL(`https://${STORAGE_ACCOUNT_NAME}.blob.core.windows.net`, pipeline);
const containerName = "auctionImages";
const blobName = "myimage.png";
const containerURL = ContainerURL.fromServiceURL(serviceURL, containerName);
const blockBlobURL = BlockBlobURL.fromContainerURL(containerURL, blobName);
await blockBlobURL.delete(aborter)
console.log(`Block blob "${blobName}" is deleted`);
});
【问题讨论】:
-
您使用的是什么版本的 Azure 存储节点 SDK?
-
"@azure/storage-blob": "^12.1.0"
标签: node.js azure azure-storage azure-blob-storage