【问题标题】:Are there any way to delete Azure Blob Container files through Javascript?有没有办法通过 Javascript 删除 Azure Blob 容器文件?
【发布时间】:2021-07-15 05:23:55
【问题描述】:

我目前有一个项目,我将在 Blob 容器中上传一些文件,并且在某些情况下我也想永久删除一些文件,但它应该通过 JavaScript。有什么办法吗?

【问题讨论】:

标签: javascript azure azure-blob-storage azure-container-instances


【解决方案1】:

试试这个:

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

  const connectionString = '<storage connection string>'
  const container = '<container name>'
  const blob = '<blob name>'

  const blobClient = BlobServiceClient.fromConnectionString(connectionString).getContainerClient(container).getBlobClient(blob);
  blobClient.deleteIfExists().then(result =>{console.log(result._response.status + " blob removed")})

如果您还有其他问题,请告诉我。

【讨论】:

    猜你喜欢
    • 2020-08-15
    • 2020-04-18
    • 1970-01-01
    • 1970-01-01
    • 2012-05-14
    • 2021-10-09
    • 2020-04-09
    • 2016-04-16
    相关资源
    最近更新 更多