首页 > 解决方案 > Azure Blob 存储 SAS ExpireOn 不起作用

问题描述

已解决,是浏览器缓存

我正在尝试从 Azure Blob 存储中获取图像,由于某种原因,ExpireOn 无法正常工作,我可以正常访问图像,但在过期时间过后,它不会使链接失效。

import { BlobSASPermissions, generateBlobSASQueryParameters, StorageSharedKeyCredential} from "@azure/storage-blob";

export async function BlobService2(){

  const accountName = process.env.ACCOUNT_NAME;
  const containerName = process.env.CONTAINER_NAME;
  const blobName = process.env.BLOB_NAME;
  const accountKey = process.env.ACCOUNT_KEY;

  const SharedKeyCredential = new StorageSharedKeyCredential(accountName , accountKey)
  
  const blobSAS = generateBlobSASQueryParameters({
    containerName, // Required
    blobName, // Required
    permissions: BlobSASPermissions.parse("r"), 
    startsOn: new Date(), // Required
    expiresOn: new Date(new Date().getTime() + 5*60000)
    },SharedKeyCredential).toString();
    

  const URL = `https://${accountName}.blob.core.windows.net/${containerName}/${blobName}?${blobSAS}`

  console.log(URL);
  
}

标签: node.jstypescriptazureazure-storageazure-blob-storage

解决方案


@Henrique E,感谢您确认您的问题已通过清除浏览器缓存得到解决。

感谢@GauravMantri 和@JohnHanley 提供您的建议。


推荐阅读