2

我无法弄清楚为什么我不断从 AWS Glacier 获得无效的 Content-Range。在我看来,我的格式遵循 RFC 2616,但我不断收到错误消息。帮助?

在此处输入图像描述

这是代码:

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);
    }
}
4

1 回答 1

3

显然我误解了 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/*.

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

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

应该:

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

德普。

于 2013-06-07T19:49:37.217 回答