2011-02-23 65 views
1

我在訪問我下載的文件時遇到問題。我可以看到 我下載的數據是通過使用didReceiveData委託 方法實現的,但一旦請求完成後,我就不會在目錄中看到該文件。另外,FWIW我正在從我的存儲桶申請一個.zip文件。ASIHTTPRequest(ASIS3ObjectRequest) - 文件未下載

-(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

啊發現問題。

首先,如果您使用downloadDestinationPath將數據寫入磁盤,則必須從實施中刪除didReceiveData委託方法。還要確保你設置了你的temporaryDownloadPath。