这里的问题是全新的 AZURE 存储帐户默认实现不支持在HTTP 206 Partial Content 的 HTTP 响应中提供正确的标头“Accept-Ranges: bytes”
要解决此问题,您需要将存储帐户的 DefaultServiceVersion 设置为版本 2013-08-15 或 later。在他们的文档中,他们说这在版本 2011-08-18 中得到了官方支持,但在我的测试中,直到我将其设置为版本 2013-08-15 才看到它。最后,我只是将其更新到最新版本 2019-02-02。稍后我将向您展示如何做到这一点。
话虽如此,您可以采取一些步骤来测试和验证此问题以及如何解决它。
创建一个全新的 AZURE 存储帐户,添加一个新容器,然后将 MP4 上传到该容器。要查看 MP4 的默认标题,请运行以下 curl 命令
curl -I https://<StorageAccount>.blob.core.windows.net/<YourContainer>/<Your>.mp4
这里是你应该看到你的回复的标题
HTTP/1.1 200 OK
Content-Length: 8655515
Content-Type: video/mp4
Last-Modified: Fri, 29 Nov 2019 21:45:12 GMT
ETag: 0x8D7751569DECA07
Server: Windows-Azure-Blob/1.0 Microsoft-HTTPAPI/2.0
x-ms-request-id: cc44ae3e-b01e-00b5-2337-e4372d000000
x-ms-version: 2009-09-19
x-ms-lease-status: unlocked
x-ms-blob-type: BlockBlob
Access-Control-Expose-Headers: x-ms-request-id,Server,x-ms-version,Content-Type,Last-Modified,ETag,x-ms-lease-status,x-ms-blob-type,Content-Length,Date,Transfer-Encoding
Access-Control-Allow-Origin: *
Date: Sat, 15 Feb 2020 19:36:37 GMT
你会看到下面的header缺少的是
Accept-Ranges: bytes
然后您可以验证当您运行以下 curl 命令时此标头将返回
curl -I -H x-ms-version:2013-08-15 https://<StorageAccount>.blob.core.windows.net/<YourContainer>/<Your>.mp4
要永久设置我使用的存储帐户版本LinqPad 和以下代码引用Windows.Azure.Storage Nuget Pacakge
var connectionString = "DefaultEndpointsProtocol=https;AccountName=<YourAcountName>;AccountKey=<YourAccountKey>;";
var storageAccount = CloudStorageAccount.Parse(connectionString);
var blobClient = storageAccount.CreateCloudBlobClient();
var props = await blobClient.GetServicePropertiesAsync();
props.Dump(); /* Here you will see that the DefaultServiceVersion is null*/
props.DefaultServiceVersion = "2019-02-02";
await blobClient.SetServicePropertiesAsync(props);
第一次运行时,您会看到 DefaultServiceVersion 为空。如果您再次运行它,您将看到 DefaultServiceVersion 将是您设置的版本。
如果你再次运行 curl 命令。
curl -I https://<StorageAccount>.blob.core.windows.net/<YourContainer>/<Your>.mp4
您将看到以下标头,其中现在包含“Accept-Ranges: bytes”标头,您的搜索将起作用。
HTTP/1.1 200 OK
Content-Length: 8655515
Content-Type: video/mp4
Last-Modified: Fri, 29 Nov 2019 21:45:12 GMT
Accept-Ranges: bytes
ETag: "0x8D7751569DECA07"
Server: Windows-Azure-Blob/1.0 Microsoft-HTTPAPI/2.0
x-ms-request-id: b95228de-f01e-0135-4596-e5d2d2000000
x-ms-version: 2019-02-02
x-ms-creation-time: Fri, 29 Nov 2019 21:45:12 GMT
x-ms-lease-status: unlocked
x-ms-lease-state: available
x-ms-blob-type: BlockBlob
x-ms-server-encrypted: true
x-ms-access-tier: Hot
x-ms-access-tier-inferred: true
Date: Mon, 17 Feb 2020 13:33:00 GMT