Как сохранить загруженный контент/данные в указанном пути в каталоге документов NSOutputStream. Если я добавляю имя файла в DD, то он работает (ex-DD/contentPath.zip), но если я добавлю путь, например DD/hello/contentPath.zip, то он не сработает. Зачем ? Я пробовал, как показано ниже -Не удалось сохранить данные в заданном каталоге каталога документов NSOutputStream
- (void) downloadCarContents:(NSString *)url forContent:(NSString *)contentPath {
//NSString *destinationPath = [self.documentDirectory getDownloadContentPath:contentPath];
AFHTTPRequestOperationManager *manager = [AFHTTPRequestOperationManager manager];
AFHTTPRequestOperation *op = [manager GET:url
parameters:nil
success:^(AFHTTPRequestOperation *operation, id responseObject) {
} failure:^(AFHTTPRequestOperation *operation, NSError *error) {
//NSLog(@"Error : %@", error.localizedDescription);
}];
NSString *documentsDirectory = [NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) objectAtIndex:0];
NSString *dest = [documentsDirectory stringByAppendingPathComponent:[NSString stringWithFormat:@"hello/%@.zip", contentPath]];// It doesn't work
//NSString *dest = [documentsDirectory stringByAppendingPathComponent:[NSString stringWithFormat:@"%@.zip", contentPath]];// It works
op.outputStream = [NSOutputStream outputStreamToFileAtPath:dest append:NO];
[op setDownloadProgressBlock:^(NSUInteger bytesRead, long long totalBytesRead, long long totalBytesExpectedToRead) {
float percentage = (float) (totalBytesRead * 100)/totalBytesExpectedToRead;
[self.delegate downloadProgression:percentage];
}];
}
Спасибо, сработало, отлично .. !!! – Nuibb