简体   繁体   中英

OpenStack SDK GetObjectSaveToFile Headers

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.

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM