如何使用 Azure Blob 创建 HTML 链接来下载链接
我正在使用Azure Blobs创建一个网站来存储内容。该网站提供搜索和索引。
当此链接是相对的时,
<a download="" href="./media5/yyy.png">Download</a>
浏览器将启动“下载”。
当文件存储在斑点中时,用户获得了一个链接:
<a download="" href="https://xxx.blob.core.windows.net/media5/yyy.png">Download</a>
但是,此导航到图像。
我需要浏览器“下载”才能工作。
但这没有做任何事情。
I am creating a website using Azure Blobs to store content. The website provides Search and Indexing.
When this link is relative,
<a download="" href="./media5/yyy.png">Download</a>
the browser kicks off a "download".
When the files are stored in Blobs, the users get a link like:
<a download="" href="https://xxx.blob.core.windows.net/media5/yyy.png">Download</a>
However, this navigates to the image.
I need the browser "download" to work.
I have tries setting the Storage Account's CORS Blade:
But this did not do anything.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
在这种情况下,CORS不会有帮助。如果要强制下载斑点,请将BLOB的内容类型属性更改为
application/ocket-stream
(或application/application/binary
)。但是,请注意,当您将BLOB的内容类型更改为
application/Octet-Stream
时,它将始终下载。您将无法在浏览器中显示斑点。CORS is not going to help in this case. If you want to force download the blob, please change the blob's content-type property to
application/octet-stream
(orapplication/binary
).However, please note that when you change the blob's content type to
application/octet-stream
, it will always be downloaded. You will not be able to display the blob in the browser.Manrti是正确的CORS没有发挥作用。我删除了存储帐户的CORS刀片。
修复是3个部分:
1:将ContentDispoistion标题设置为“附加”
2:您必须使用SAS URL才能返回内容分配标题:
3:HTML链接:
Manrti is correct CORS is not in play. I deleted the Storage Account's CORS Blade.
The fix is 3 parts:
1: Set ContentDispoistion header to "attached"
2: You must use a SAS Url to have the Content-Disposition header be returned:
3: HTML Link: