【发布时间】:2021-09-22 16:19:51
【问题描述】:
我正在尝试使用Azure.Storage.Files.Shares 中提供的工具从 Azure 文件共享下载一个空文件。下载包含超过 0 个字节的文件可以正常工作。但是,在我的集成测试中,我正在创建/下载空文件。对于我的测试来说,只使用填充文件并不是什么大问题,但是在我们的应用程序中意外上传并选择下载一个空文件并不是不合理的。那么问题来了:
我收到 InvalidRange 错误:
Status: 416 (The range specified is invalid for the current size of the resource.)
ErrorCode: InvalidRange
Content:
<?xml version="1.0" encoding="utf-8"?><Error><Code>InvalidRange</Code><Message>The range specified is invalid for the current size of the resource.
RequestId:9f04885b-401a-005e-80fa-77d94a000000
Time:2021-07-13T15:16:59.9547272Z</Message></Error>
Headers:
Content-Range: bytes */0
x-ms-request-id: 9f04885b-401a-005e-80fa-77d94a000000
x-ms-client-request-id: a6ee7be7-7ae9-4587-b28c-d6a15cd499e8
x-ms-version: 2020-08-04
x-ms-error-code: InvalidRange
Content-Length: 249
Content-Type: application/xml
Date: Tue, 13 Jul 2021 15:16:59 GMT
Server: Windows-Azure-File/1.0 Microsoft-HTTPAPI/2.0
我的下载代码是this example code提供的代码:
ShareFileDownloadInfo download = file.Download();
using (FileStream stream = File.OpenWrite(localFilePath))
{
download.Content.CopyTo(stream);
}
同样,它适用于非空文件。 The documentation for the underlying storage REST API 表示“范围”是一个可选参数,如果留空,默认情况下将下载所有文件内容。我知道可以这样做,因为这些文件可以通过 Azure 门户手动下载。
这是一个错误还是这个下载代码不完整?
【问题讨论】:
-
看来您在 SDK 中发现了一个错误。请在 SDK 的 Github 存储库上打开一个新问题。
标签: c# .net azure azure-storage azure-sdk