2013-09-02 3 views
1

압축을 푼 후에 URL에서 zip 파일을 다운로드해야합니다. 문제의 파일을 Documents 폴더에 넣습니다. 그것은 아주 다운로드하지 않습니다. 이 코드입니다 : 문서에서ASIHTTPRequest가 zip 파일을 다운로드하지 않습니다.

NSURL *urltoZip = [NSURL URLWithString: urlZip]; 

NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES); 

NSString *filePathAndDirectory1 = [[paths objectAtIndex:0] stringByAppendingPathComponent:[NSString stringWithFormat:@"/ZipPackages"]]; 

if (![[NSFileManager defaultManager] fileExistsAtPath:filePathAndDirectory1]) 
    [[NSFileManager defaultManager] createDirectoryAtPath:filePathAndDirectory1 withIntermediateDirectories:NO attributes:nil error:&error]; 

NSString *filePathAndDirectory = [filePathAndDirectory1 stringByAppendingPathComponent:[NSString stringWithFormat:@"/%@", self.nomePackage]]; 


if (![[NSFileManager defaultManager] fileExistsAtPath:filePathAndDirectory]) 
    [[NSFileManager defaultManager] createDirectoryAtPath:filePathAndDirectory withIntermediateDirectories:NO attributes:nil error:&error]; 


NSLog(@"fileName zip %@", filePathAndDirectory); 
/* fileName zip /var/mobile/Applications/5256198E-72FC-4054-BFD3-BC1600BDC01C/Documents/ZipPackages/HtmlInfo */ 

ASIHTTPRequest *requestZip = [ASIHTTPRequest requestWithURL:urltoZip]; 
[requestZip setDownloadDestinationPath:filePathAndDirectory]; //in this path is not saved anything 
[requestZip startSynchronous]; 

response =[requestZip responseString]; 

    NSLog(@" response zip %@", response); 
    /*response zip 

    <!DOCTYPE html> 

    <html lang="en"> 

     <head><meta charset="utf-8" /><title> 

     .......... 

     </footer> 

     </form> 

    </body> 

    </html>*/ 

파일의 흔적이없는 폴더. 어떻게해야합니까? 코드 지능

+1

마지막 NSLog는 zip 파일을 다운로드하지 않고 해당 파일을 다운로드 할 수있는 html 페이지라고 추측합니다. 올바른 URL을 사용하려면 브라우저에서 URL을 열고 파일 다운로드가 즉시 시작되는지 확인하십시오. –

+0

URL을 수정했지만 여전히 저장되어 있습니다. 빌드 폴더에서 뭔가 잘못 처리 한 적이 있습니까? –

답변

0

:

NSString *filePathAndDirectory1 = [[paths objectAtIndex:0] stringByAppendingPathComponent:[NSString stringWithFormat:@"/ZipPackages"]]; 

"/"당신이 "stringByAppendingPathComponent :"를 사용하는 경우 필요하지가 않습니다 다음과 같은 코드를 변경 :

NSString *filePathAndDirectory1 = [[paths objectAtIndex:0] stringByAppendingPathComponent:[NSString stringWithFormat:@"ZipPackages"]]; 

지금 작동 할 수 있습니다 다시 시도하십시오.

관련 문제