|
@ -454,7 +454,7 @@
|
454
|
454
|
// 1.如果目录不存在,创建
|
455
|
455
|
NSRange range = [filePathStr rangeOfString:@"/" options:NSBackwardsSearch];
|
456
|
456
|
NSString *dir = [filePathStr substringToIndex:range.location], *fileName = [filePathStr substringFromIndex:range.location];
|
457
|
|
NSString *dirPath = [WDUtility dirInDocument:dir];
|
|
457
|
NSString *dirPath = [[WDUtility dirInDocument:FILE_TMP] stringByAppendingPathComponent:dir];
|
458
|
458
|
NSString *savePath = [dirPath stringByAppendingString:fileName];
|
459
|
459
|
|
460
|
460
|
// 2.将数据写到文件中
|
|
@ -498,36 +498,4 @@
|
498
|
498
|
[self callback: ret ? @"0" : @"1"];
|
499
|
499
|
}
|
500
|
500
|
|
501
|
|
- (void)downloadFileToDocument:(NSArray *)param {
|
502
|
|
NSAssert(param && [param isKindOfClass:[NSArray class]] && param.count, @"参数错误");
|
503
|
|
|
504
|
|
NSString *resPath = param[0];
|
505
|
|
NSAssert(resPath && resPath.length, @"参数resPath错误");
|
506
|
|
|
507
|
|
NSString *filePath = param[1];
|
508
|
|
NSAssert(filePath && filePath.length, @"参数filePath错误");
|
509
|
|
|
510
|
|
NSData *resData = [NSData dataWithContentsOfURL:[NSURL URLWithString:resPath]];
|
511
|
|
NSAssert(resData && resData.length, @"下载失败");
|
512
|
|
|
513
|
|
NSMutableString *filePathStr = [NSMutableString stringWithString:filePath];
|
514
|
|
|
515
|
|
// 处理以“/”开头的路径
|
516
|
|
if ([filePathStr hasPrefix:@"/"]) {
|
517
|
|
filePathStr = [NSMutableString stringWithString:[filePathStr substringFromIndex:1]];
|
518
|
|
}
|
519
|
|
|
520
|
|
// 1.如果目录不存在,创建
|
521
|
|
NSRange range = [filePathStr rangeOfString:@"/" options:NSBackwardsSearch];
|
522
|
|
NSString *dir = [filePathStr substringToIndex:range.location];
|
523
|
|
NSString *fileName = [filePathStr substringFromIndex:range.location];
|
524
|
|
NSString *dirPath = [[WDUtility dirInDocument:FILE_TMP] stringByAppendingPathComponent:dir];
|
525
|
|
NSString *savePath = [dirPath stringByAppendingString:fileName];
|
526
|
|
|
527
|
|
// 2.将数据写到文件中
|
528
|
|
BOOL ret = [resData writeToFile:savePath atomically:YES];
|
529
|
|
|
530
|
|
[self callback:ret ? @"0" : @"1"];
|
531
|
|
}
|
532
|
|
|
533
|
501
|
@end
|