|
@@ -28,10 +28,22 @@
|
|
|
|
|
|
self.downloadFileTaskUid = [iTools getTaskUidStr];
|
|
|
|
|
|
- NSString * commandStr = [RCCommandHelp applyForDownloadFileBy:self.downloadFileTaskUid withFilePath:self.curDownloadFileModel.path withPosition:self.curDownloadFileModel.didDownloadBytes];
|
|
|
-
|
|
|
- [self.commandChannelManager rc_sendData:commandStr];
|
|
|
+ NSString *fileName = [self.curDownloadFileModel getFileNameFun];
|
|
|
+ NSString*pathStr = [cachesFileManager getFilePathWithName:fileName type:DownLoadFileType];
|
|
|
+ long didDownloadBytes = 0;
|
|
|
+
|
|
|
+ NSFileManager *manager0 = [NSFileManager defaultManager];
|
|
|
+ if([manager0 fileExistsAtPath:pathStr]) {
|
|
|
+ NSFileHandle *fileHandle = [NSFileHandle fileHandleForReadingAtPath:pathStr]; // 创建文件句柄
|
|
|
+ if (fileHandle) {
|
|
|
+ didDownloadBytes = [fileHandle seekToEndOfFile];
|
|
|
+ // 关闭文件句柄
|
|
|
+ [fileHandle closeFile];
|
|
|
+ }
|
|
|
+ }
|
|
|
|
|
|
+ NSString * commandStr = [RCCommandHelp applyForDownloadFileBy:self.downloadFileTaskUid withFilePath:self.curDownloadFileModel.path withPosition:didDownloadBytes];
|
|
|
+ [self.commandChannelManager rc_sendData:commandStr];
|
|
|
}
|
|
|
|
|
|
- (void)downloadFileFunServiceResponseFun:(NSData *)fileData with:(BOOL)isDownloadDone
|
|
@@ -54,8 +66,6 @@
|
|
|
[fileHandle writeData:fileData];
|
|
|
}
|
|
|
|
|
|
- //[fileHandle writeData:fileData];
|
|
|
-
|
|
|
endOfFile = [fileHandle seekToEndOfFile];
|
|
|
// 关闭文件句柄
|
|
|
[fileHandle closeFile];
|
|
@@ -69,10 +79,22 @@
|
|
|
|
|
|
self.curDownloadFileModel.didDownloadBytes = didDownloadBytes;
|
|
|
|
|
|
+ if(isDownloadDone){
|
|
|
+ NSInteger i;
|
|
|
+ }
|
|
|
+
|
|
|
+ if(endOfFile == self.curDownloadFileModel.length){
|
|
|
+ NSInteger i;
|
|
|
+ }
|
|
|
+
|
|
|
if(isDownloadDone || endOfFile == self.curDownloadFileModel.length){
|
|
|
[self handleDownloadDoneFun];
|
|
|
}
|
|
|
else{//获取下一片
|
|
|
+ if(isDownloadDone){
|
|
|
+ NSInteger i;
|
|
|
+ }
|
|
|
+
|
|
|
NSString * commandStr = [RCCommandHelp applyForDownloadFileBy:self.downloadFileTaskUid withFilePath:self.curDownloadFileModel.path withPosition:didDownloadBytes];
|
|
|
[self.commandChannelManager rc_sendData:commandStr];
|
|
|
}
|
|
@@ -81,7 +103,7 @@
|
|
|
|
|
|
- (void)handleDownloadDoneFun
|
|
|
{
|
|
|
- if([self.curDownloadFileModel.fileType isEqualToString:@"jpg"]){
|
|
|
+ if([self.curDownloadFileModel.fileType isEqualToString:@".jpg"]){
|
|
|
NSString *fileName = [self.curDownloadFileModel getFileNameFun];
|
|
|
NSString*pathStr = [cachesFileManager getFilePathWithName:fileName type:DownLoadFileType];
|
|
|
UIImage *image = [UIImage imageWithContentsOfFile:pathStr];
|
|
@@ -94,7 +116,6 @@
|
|
|
[self loadVideoFinished];
|
|
|
}
|
|
|
|
|
|
- [[downloadManager shareInstance] DownloadFileDoneOneFileFun];
|
|
|
}
|
|
|
|
|
|
|
|
@@ -105,7 +126,17 @@
|
|
|
PHAssetChangeRequest *req = [PHAssetChangeRequest creationRequestForAssetFromImage:image];
|
|
|
|
|
|
} completionHandler:^(BOOL success, NSError * _Nullable error) {
|
|
|
- NSLog(@"success = %d, error = %@", success, error);
|
|
|
+ //NSLog(@"success = %d, error = %@", success, error);
|
|
|
+ if (success) {
|
|
|
+ HLog(@"已将视频保存至相册");
|
|
|
+ NSString *fileName = [self.curDownloadFileModel getFileNameFun];
|
|
|
+ [cachesFileManager removeItemAtPath:fileName type:DownLoadFileType error:nil];
|
|
|
+
|
|
|
+ } else {
|
|
|
+ HLog(@"未能将视频保存至相册");
|
|
|
+ }
|
|
|
+
|
|
|
+ [[downloadManager shareInstance] DownloadFileDoneOneFileFun];
|
|
|
}];
|
|
|
}
|
|
|
|
|
@@ -120,10 +151,15 @@
|
|
|
fileURLWithPath:pathStr]];
|
|
|
} completionHandler:^(BOOL success, NSError * _Nullable error) {
|
|
|
if (success) {
|
|
|
- NSLog(@"已将视频保存至相册");
|
|
|
+ HLog(@"已将图片保存至相册");
|
|
|
+ //NSString *fileName = [self.curDownloadFileModel getFileNameFun];
|
|
|
+ [cachesFileManager removeItemAtPath:fileName type:DownLoadFileType error:nil];
|
|
|
+
|
|
|
} else {
|
|
|
- NSLog(@"未能保存视频到相册");
|
|
|
+ HLog(@"未能将图片保存至相册");
|
|
|
}
|
|
|
+
|
|
|
+ [[downloadManager shareInstance] DownloadFileDoneOneFileFun];
|
|
|
}];
|
|
|
}
|
|
|
@end
|