2

除了暂停/恢复功能外,一切似乎都运行良好。我的问题是,当下载尝试从中断的地方继续时,设置标题范围但无法正常工作。当我下载 zip 文件并解压时,解压后的文件扩展名为 download.zip.cpgz。请解决我的问题。

我的代码:

 **UIWebView* webView = [[UIWebView alloc] initWithFrame:CGRectZero];
    NSString* secretAgent = [webView stringByEvaluatingJavaScriptFromString:@"navigator.userAgent"];
     NSLog(@"user aggent %@",secretAgent);
    if([[NSFileManager defaultManager] fileExistsAtPath:_path]){
        NSDictionary *fileDictionary = [[NSFileManager defaultManager] fileAttributesAtPath:_path traverseLink:YES];
        unsigned long long int h = [fileDictionary fileSize];
        _textField.text = self.textField.text;
        //[self performSelectorInBackground:@selector(downloadZipfile) withObject:nil];
//        NSURLRequest *request=[NSURLRequest requestWithURL:[NSURL URLWithString:_textField.text]
//                                  
//                                                  cachePolicy:NSURLRequestUseProtocolCachePolicy
//                                  
//                                              timeoutInterval:60.0];
        //NSFileSize *fileSize = [NSFileSize]
        NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:[NSURL URLWithString:self.textField.text]];
        NSString *range = @"bytes=";
        range = [range stringByAppendingString:[[NSNumber numberWithInt:h] stringValue]];
        range = [range stringByAppendingString:@"-"];
        [request setHTTPMethod:@"GET"];
        [request setValue:@"keep-live"      forHTTPHeaderField:@"Connection"];
        [request setValue:range     forHTTPHeaderField:@"Keep-Alive"];
        [request setValue:secretAgent       forHTTPHeaderField:@"User-Agent"];
        [request setValue:range forHTTPHeaderField:@"Range"];
                NSLog(@"range set %@",range);

        // create the connection with the request

        // and start loading the data
       _downloadConeection=[[NSURLConnection alloc] initWithRequest:request delegate:self];**
4

0 回答 0