img src 到 azure blob 存储图像无法从 html 标签工作
img src to azure blob storage image not working from html tag
我开始使用 Azure blob 存储并上传了一些图像。我还添加了一个自定义域。所以现在如果我使用浏览器并转到 http://images.example.com/some/fileName.jpg
我可以看到图像。但是如果我像这样在 img
标签中使用这个 url:
<img src="http://images.example.com/some/fileName.jpg" />
图像已损坏。知道为什么吗?
更新
到目前为止,我发现如果我在标签中使用原来的 link,它就可以正常工作:
<img src="http://example.blob.core.windows.net/images/some/fileName.jpg" />
所以我猜问题出在自定义域上。
内容类型设置为 image/jpg
@ShiranDror,有一个已回答的 SO 线程 Getting broken images from blob storage in Azure websites 与您的相似。
问题可能是由操作延迟引起的。请尝试为 Blob 存储客户端设置操作的开始时间。
对于 C#,将 StartTime
设置为 OperationContext
. And for Java, using the function setClientTimeInMs
为 OperationContext
。
好吧,我将其缩小为 CNAME 有问题。我最终只是删除了 CNAME 和存储,然后重新创建了它们。现在可以了。我不确定到底出了什么问题,但它与通过自定义域访问文件时的 return MIME 有关。谢谢大家的帮助。
我开始使用 Azure blob 存储并上传了一些图像。我还添加了一个自定义域。所以现在如果我使用浏览器并转到 http://images.example.com/some/fileName.jpg
我可以看到图像。但是如果我像这样在 img
标签中使用这个 url:
<img src="http://images.example.com/some/fileName.jpg" />
图像已损坏。知道为什么吗?
更新
到目前为止,我发现如果我在标签中使用原来的 link,它就可以正常工作:
<img src="http://example.blob.core.windows.net/images/some/fileName.jpg" />
所以我猜问题出在自定义域上。
内容类型设置为 image/jpg
@ShiranDror,有一个已回答的 SO 线程 Getting broken images from blob storage in Azure websites 与您的相似。
问题可能是由操作延迟引起的。请尝试为 Blob 存储客户端设置操作的开始时间。
对于 C#,将 StartTime
设置为 OperationContext
. And for Java, using the function setClientTimeInMs
为 OperationContext
。
好吧,我将其缩小为 CNAME 有问题。我最终只是删除了 CNAME 和存储,然后重新创建了它们。现在可以了。我不确定到底出了什么问题,但它与通过自定义域访问文件时的 return MIME 有关。谢谢大家的帮助。