|
@@ -145,7 +145,10 @@
|
|
|
else if([self.curDownloadFileModel.fileType isEqualToString:@"video"]){
|
|
|
[self loadVideoFinished];
|
|
|
}
|
|
|
-
|
|
|
+ else
|
|
|
+ {
|
|
|
+ [self loadOtherDataFinished];
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
|
|
@@ -197,4 +200,57 @@
|
|
|
[[downloadManager shareInstance] DownloadFileDoneOneFileFun];
|
|
|
}];
|
|
|
}
|
|
|
+
|
|
|
+//下载音频 文件等
|
|
|
+- (void)loadOtherDataFinished
|
|
|
+{
|
|
|
+ [[downloadManager shareInstance] DownloadFileDoneOneFileFun];
|
|
|
+
|
|
|
+ NSString *fileName = [self.curDownloadFileModel getFileNameFun];
|
|
|
+ NSString*filePath = [cachesFileManager getFilePathWithName:fileName type:DownLoadFileType];
|
|
|
+
|
|
|
+ if (![[NSFileManager defaultManager] fileExistsAtPath:filePath]){
|
|
|
+ HLog(@"没有找到文件:%@",fileName);
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+ NSURL * fileURL = [NSURL fileURLWithPath:filePath];
|
|
|
+ UIDocumentPickerViewController *documentPickerVC = [[UIDocumentPickerViewController alloc] initWithURL:fileURL inMode:UIDocumentPickerModeExportToService];
|
|
|
+ // 设置代理
|
|
|
+ documentPickerVC.delegate = self;
|
|
|
+ // 设置模态弹出方式
|
|
|
+ documentPickerVC.modalPresentationStyle = UIModalPresentationFormSheet;
|
|
|
+ [self.navigationController presentViewController:documentPickerVC animated:YES completion:nil];
|
|
|
+}
|
|
|
+
|
|
|
+
|
|
|
+#pragma mark - UIDocumentPickerDelegate
|
|
|
+- (void)documentPicker:(UIDocumentPickerViewController *)controller didPickDocumentsAtURLs:(NSArray<NSURL *> *)urls {
|
|
|
+ // 获取授权
|
|
|
+ BOOL fileUrlAuthozied = [urls.firstObject startAccessingSecurityScopedResource];
|
|
|
+ if (fileUrlAuthozied) {
|
|
|
+ // 通过文件协调工具来得到新的文件地址,以此得到文件保护功能
|
|
|
+ NSFileCoordinator *fileCoordinator = [[NSFileCoordinator alloc] init];
|
|
|
+ NSError *error;
|
|
|
+
|
|
|
+ [fileCoordinator coordinateReadingItemAtURL:urls.firstObject options:0 error:&error byAccessor:^(NSURL *newURL) {
|
|
|
+ // 读取文件
|
|
|
+ NSString *fileName = [newURL lastPathComponent];
|
|
|
+ NSError *error = nil;
|
|
|
+ //NSData *fileData = [NSData dataWithContentsOfURL:newURL options:NSDataReadingMappedIfSafe error:&error];
|
|
|
+ if (error) {
|
|
|
+ // 读取出错
|
|
|
+ } else {
|
|
|
+ // 上传
|
|
|
+ NSLog(@"fileName : %@", fileName);
|
|
|
+ [cachesFileManager removeItemAtPath:fileName type:DownLoadFileType error:nil];
|
|
|
+ }
|
|
|
+ }];
|
|
|
+ [urls.firstObject stopAccessingSecurityScopedResource];
|
|
|
+ } else {
|
|
|
+ // 授权失败
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+
|
|
|
@end
|