c# - 继续从 AWS Glacier Multipart Upload 获得 "Invalid Content-Range"响应

标签 c# amazon-web-services amazon-glacier

我不明白为什么我总是从 AWS Glacier 获取无效的内容范围。在我看来,我的格式遵循 RFC 2616,但我一直收到错误消息。帮忙?

enter image description here

代码如下:

using (var FileStream = new System.IO.FileStream(ARCHIVE_FILE, FileMode.Open))
{
    while (FileStream.Position < FileInfo.Length)
    {
        string Range = "Content-Range:bytes " + FileStream.Position.ToString() + "-" + (FileStream.Position + Size - 1).ToString() + "/*";

        var request = new Amazon.Glacier.Model.UploadMultipartPartRequest()
        {
            AccountId = "-",
            VaultName = VAULT_NAME,
            Body = Amazon.Glacier.GlacierUtils.CreatePartStream(FileStream, Size),
            UploadId = UploadId,
            Range = Range,
            StreamTransferProgress = Progress
        };
        //request.SetRange(FileStream.Position, FileStream.Position + Size - 1);
        response = GlacierClient.UploadMultipartPart(request);
    }
}

最佳答案

显然我误解了 Intellisense 描述:

//
// Summary:
//     Identifies the range of bytes in the assembled archive that will be uploaded
//     in this part. Amazon Glacier uses this information to assemble the archive
//     in the proper sequence. The format of this header follows RFC 2616. An example
//     header is Content-Range:bytes 0-4194303/*.

您不应该包含 header 本身的名称,因此这一行:

string Range = "Content-Range:bytes " + FileStream.Position.ToString() + "-" + (FileStream.Position + Size - 1).ToString() + "/*";

应该是:

string Range = "bytes " + FileStream.Position.ToString() + "-" + (FileStream.Position + Size - 1).ToString() + "/*";

德普。

关于c# - 继续从 AWS Glacier Multipart Upload 获得 "Invalid Content-Range"响应,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16991509/

相关文章:

amazon-web-services - EC2 Container Registry入门

amazon-web-services - Amazon S3 生命周期规则 : Archive files have recent dates

java - Archive TransferManagerBuilder 无法通过区域提供商链找到区域

c# - WPF 和 ObservableCollection<T>

c# - 读取从ASMX返回的JSON数据

c# - 无法解决 “Sqlparameter is already contained by another SqlparameterCollection”

c# - 无法将类型 'System.Collections.Generic.List<AnonymousType#1>' 隐式转换为 'System.Collections.Generic.List<Model.tblLaborBankAccount>'

amazon-web-services - 如何在相对复杂的基础设施中正确自动扩展 AWS EC2 实例组?

amazon-web-services - 将图像和文本字段添加到 Quicksight 仪表板

amazon-web-services - 列出具有特定存储类的 S3 存储桶对象