如何获取存储在Azure存储帐户中的数字文件的下载URL [英] How to get download url of a digital file stored in an Azure storage account

查看:54
本文介绍了如何获取存储在Azure存储帐户中的数字文件的下载URL的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Azure Blob存储中存储了数字文件之后,我想在我的静态网站中提供指向该文件的 link (没有 no 服务器端代码).当用户单击该链接时,用户应该能够将该数字文件下载到他/她的计算机上.问题:如何获取存储在Azure blob存储中的数字文件的 url ?

After storing a digital file in Azure blob storage, I want to provide a link to that file in my static website (that has no server side code). When a user clicks on that link user should be able to download that digital file to his/her computer. Question: How do you get the url of a digital file stored in Azure blob storage?

推荐答案

Azure存储中的每个Blob都具有以下格式的URL:

Each blob in Azure Storage has a URL of the following format:

https://account.blob.core.windows.net/container/blob

位置:

account 是您的存储帐户的名称, container 是您的blob容器的名称 blob`是您的blob的名称

account is the name of your storage account, container is the name of your blob containerandblob` is the name of your blob.

现在,您的要求是,应提示用户直接下载文件而不使用任何服务器端代码,这是您需要做的其他事情:

Now that your requirement is that a user should be prompted to download the file directly without using any server-side code, these are the additional things you would need to do:

  1. 确保将blob容器的ACL设置为 Blob (推荐)或 Public .如果将ACL设置为 Private ,则需要一个 Shared Access Signature(SAS),并且这将需要一些服务器端代码.
  2. 将Blob的 content-type 设置为 application/octet-stream (Azure存储中任何Blob的默认内容类型)或设置 content-disposition 属性附加到 attachment;filename =您的文件名" 强制文件下载,而不是仅在浏览器中显示.推荐的方法是使用 content-disposition 属性.
  1. Make sure that the blob container's ACL is either set to Blob (recommended) or Public. If you set the ACL to Private, then you would need a Shared Access Signature (SAS) and that would require some server-side code.
  2. Either set the content-type of the blob to application/octet-stream (default content type for any blob in Azure Storage) or set the content-disposition property to attachment; filename="your file name" to force the file download instead of displaying it inside the browser only. Recommended approach is to use content-disposition property.

这篇关于如何获取存储在Azure存储帐户中的数字文件的下载URL的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆