如何获取存储在 Azure 存储帐户中的数字文件的下载 URL

nam*_*nam 4 azure azure-storage azure-blob-storage

存储digital filein后Azure blob storage,我想在 my (具有服务器端代码)link中为该文件提供 a 。当用户单击该链接时,用户应该能够将该数字文件下载到他/她的计算机上。问题:如何获取存储在 Azure Blob 存储中的数字文件的属性?static websitenourl

Gau*_*tri 8

Azure 存储中的每个 blob 都有一个以下格式的 URL:

https://account.blob.core.windows.net/container/blob
Run Code Online (Sandbox Code Playgroud)

在哪里:

account是您的存储帐户的名称,container是您的 Blob 容器的名称andblob` 是您的 Blob 的名称。

现在您的要求是应提示用户直接下载文件而不使用任何服务器端代码,以下是您需要执行的其他操作:

  1. 确保 Blob 容器的 ACL 设置为Blob(推荐)或Public。如果将 ACL 设置为Private,那么您将需要 aShared Access Signature (SAS)并且需要一些服务器端代码。
  2. content-typeBlob 的 属性设置为application/octet-stream(Azure 存储中任何 Blob 的默认内容类型),或者将该content-disposition属性设置为attachment; filename="your file name"来强制下载文件,而不是仅在浏览器中显示它。推荐的方法是使用content-disposition属性。