Search code examples
c#amazon-web-servicesamazon-glacier

Keep getting "Invalid Content-Range" response from AWS Glacier Multipart Upload


I can't figure out why I keep getting an invalid Content-Range from AWS Glacier. It looks to me like my format follows RFC 2616 but I keep getting an error. Help?

enter image description here

Here's the code:

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

Solution

  • Apparently I misinterpreted the Intellisense description:

    //
    // 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/*.
    

    You're not supposed to include the name of the header itself so this line:

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

    Should be:

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

    Derp.