gpt4 book ai didi

c# - 检查 Azure CDN 图像是否存在

转载 作者:行者123 更新时间:2023-11-30 21:49:55 26 4
gpt4 key购买 nike

有没有办法使用任何 .Net Azure 库来检查 CDN 上是否存在资源。我可以检查 blob 是否存在,但没有遇到任何可以检查它是否也存在于 CDN 上的内容

最佳答案

假设您的 BLOB URL 是:

http://foo.blob.core.windows.net/cdn/test.png

并且您的 CDN 端点是 bar.vo.msecnd.net

只需在 http://bar.vo.msecnd.net/cdn/test.png 上执行 HTTP HEAD 请求即可查看该文件是否存在。

解释this answer中提交的代码

HttpWebResponse response = null;
var request = (HttpWebRequest)WebRequest.Create("http://bar.vo.msecnd.net/cdn/test.png");
request.Method = "HEAD";


try
{
response = (HttpWebResponse)request.GetResponse();
}
catch (WebException ex)
{
/* do something here */
}
finally
{
// Don't forget to close your response.
if (response != null)
{
response.Close()
}
}

关于c# - 检查 Azure CDN 图像是否存在,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36658317/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com