ASIHTTPRequest(ASIS3ObjectRequest) - 未下载文件

时间:2011-02-23 14:12:26

标签: objective-c ios asihttprequest

我在访问下载的文件时遇到问题。我知道 我下载的数据是使用didReceiveData委托来完成的 方法,但一旦请求,我从未在目录中看到该文件 完了。另外,FWIW我正从我的桶中请求.zip文件。

-(void)downloadZipFile 
{ 
  ASIS3ObjectRequest *request = [ASIS3ObjectRequest 
requestWithBucket:bucket key:keyPath]; 
    [request setSecretAccessKey:secretAccessKey]; 
    [request setAccessKey:accessKey]; 
    [request setDelegate:self]; 
    [request setDownloadDestinationPath:[[self documentsDirectory] 
stringByAppendingPathComponent:@"test.zip"]]; 
    [request startSynchronous]; 
} 

- (void)requestFinished:(ASIHTTPRequest *)request 
{ 
    NSError *error; 
    NSFileManager *fileManager = [[NSFileManager alloc] init]; 
    NSLog(@"Documents directory: %@", [fileManager 
contentsOfDirectoryAtPath:[self documentsDirectory] error:&error]); 
   //logging the contents of my documents directory shows that the file I downloaded is not there 
    [fileManager release]; 
} 

- (NSString *)documentsDirectory {
    NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory,
                                                         NSUserDomainMask, YES);
    return [paths objectAtIndex:0];
} 

非常感谢任何帮助。

1 个答案:

答案 0 :(得分:1)

啊,发现了问题。

首先,如果您使用downloadDestinationPath将数据写入磁盘,则必须从实现中删除didReceiveData委托方法。另外,请确保设置temporaryDownloadPath。