OpenStack SDK GetObjectSaveToFile Headers

160 views Asked by At

I am trying to download a file using the openstack sdk from rackspace files. If the file already exists I want to use the range header to continue writing where it left off. According to their documentation this can be accomplished. The openstack sdk documentation says I can set the range header. Here is my code:

Dictionary<string, string> headers = new Dictionary<string,string>();
        if (File.Exists(@"C:\path\to\file.zip"))
        {
            long iExistLen = 0;
            System.IO.FileInfo fINfo =
              new System.IO.FileInfo(@"C:\path\to\file.zip");
            iExistLen = fINfo.Length;

            headers.Add("Range", "bytes="+iExistLen+"-");
        }

        CloudIdentity cloudIdentity = new CloudIdentity()
        {
            APIKey = apikey,
            Username = username
        };

        CloudFilesProvider cloudFilesProvider = new CloudFilesProvider(cloudIdentity);
        cloudFilesProvider.GetObjectSaveToFile(containerName, @"C:\path\to\", fileName, "file.zip", 65536, headers);

When I run this I get the following error:

The 'Range' header must be modified using the appropriate property or method.

Any help is appreciated.

Thanks.

1

There are 1 answers

3
Yegor Korotetskiy On

Some common headers are considered restricted and are either exposed directly by the API (such as Content-Type) or protected by the system and cannot be changed. Range is one of that headers. Full list is:

Accept
Connection
Content-Length
Content-Type
Date
Expect
Host
If-Modified-Since
Range
Referer
Transfer-Encoding
User-Agent
Proxy-Connection