爲什麼在服務器上沒有人時下載文件?它使用html代碼創建一個文件。比較服務器上的url文件
我的代碼是在這裏:
dataPathCustomerinfo = [NSHomeDirectory() stringByAppendingPathComponent:@"Documents/Customerinfo"];
if (![[NSFileManager defaultManager] fileExistsAtPath:dataPathCustomerinfo]) {
[[NSFileManager defaultManager] createDirectoryAtPath:dataPathCustomerinfo withIntermediateDirectories:NO attributes:nil error:nil];
}
//Ordnerpfad Customerinfo
directoryContentCustomerinfo = [[NSFileManager defaultManager] contentsOfDirectoryAtPath:dataPathCustomerinfo error:&error];
numberOfFileInFolderCustomerinfo = [directoryContentCustomerinfo count];
// NSLog(@"Pfad %i",numberOfFileInFolderCustomerinfo);
/////URL Abfrage Customerinfo
if (numberOfFileInFolderCustomerinfo >= 0) {
int anz = numberOfFileInFolderCustomerinfo+1;
URLCustomerinfo = [NSURL URLWithString:[NSString stringWithFormat:@"https://www.mydomain.org/assets/Uploads/csv/customerinfo/%i_..customerinfo.csv",anz]];
if (URLCustomerinfo) {
NSLog(@"File download");
NSURLRequest *request = [NSURLRequest requestWithURL:URLCustomerinfo];
downloadTask = [manager downloadTaskWithRequest:request progress:nil destination:^NSURL *(NSURL *targetPath, NSURLResponse *response) {
NSURL *documentsDirectoryPath = [NSURL fileURLWithPath:dataPathCustomerinfo];
return [documentsDirectoryPath URLByAppendingPathComponent:[response suggestedFilename]];
}completionHandler:^(NSURLResponse *response, NSURL *filePath, NSError *error) {
NSLog(@"File download to: %@",filePath);
}];
[downloadTask resume];
} else {
NSLog(@"nothing for download");
}
NSLog(@"file in folder customerinfo: %i",anz);
}
是,告訴你一個html文件,出事了? 404代碼,50x代碼。 – vikingosegundo
btw:如果api,block或方法調用確實爲您提供錯誤對象,則應該使用它。 – vikingosegundo
實際上它說沒有文件,但在第三次啓動應用程序時,它會下載具有較高編號的文件,但這不在服務器上。所以它下載的HTML。 – deni