Sfoglia il codice sorgente

1.同步主干日志文件上传相关

huangxiaodong 2 mesi fa
parent
commit
0256d6da1b
23 ha cambiato i file con 452 aggiunte e 2040 eliminazioni
  1. 22 0
      创维盒子/code/Assets.xcassets/NAS/uploadFile_file_bigger.imageset/Contents.json
  2. BIN
      创维盒子/code/Assets.xcassets/NAS/uploadFile_file_bigger.imageset/uploadFile_file_bigger@2x.png
  3. BIN
      创维盒子/code/Assets.xcassets/NAS/uploadFile_file_bigger.imageset/uploadFile_file_bigger@3x.png
  4. 5 5
      创维盒子/code/Class/Set/previewFile/view/previewToUploadFileView.m
  5. 0 218
      创维盒子/code/Class/Set/previewFile/view/previewToUploadFileView~.m
  6. 1 1
      创维盒子/code/Class/Set/uploadFile/model/uploadFileDataModel.h
  7. 4 0
      创维盒子/code/Class/Set/uploadFile/uploadFileManager/cachesFileManager.h
  8. 5 0
      创维盒子/code/Class/Set/uploadFile/uploadFileManager/cachesFileManager.m
  9. 3 0
      创维盒子/code/Class/Set/uploadFile/uploadFileRecordViewController.h
  10. 28 0
      创维盒子/code/Class/Set/uploadFile/uploadFileRecordViewController.m
  11. 4 1
      创维盒子/code/Class/Set/uploadFile/uploadFileView/uploadFileRecordCell.m
  12. 3 0
      创维盒子/code/Helpers/iTools.h
  13. 25 0
      创维盒子/code/Helpers/iTools.m
  14. 24 0
      创维盒子/code/NAS/DocumentPickerManager/DocumentPickerManager.h
  15. 131 0
      创维盒子/code/NAS/DocumentPickerManager/DocumentPickerManager.m
  16. 23 5
      创维盒子/code/NAS/NASViewController.m
  17. 47 7
      创维盒子/code/NAS/nasUploadManager/nasMixUploadManager.m
  18. 0 987
      创维盒子/code/NAS/nasUploadManager/nasMixUploadManager~.m
  19. 3 0
      创维盒子/code/NAS/nasUploadManager/nasUploadFileManager.h
  20. 104 15
      创维盒子/code/NAS/nasUploadManager/nasUploadFileManager.m
  21. 0 52
      创维盒子/code/NAS/nasUploadManager/nasUploadFileManager~.h
  22. 0 749
      创维盒子/code/NAS/nasUploadManager/nasUploadFileManager~.m
  23. 20 0
      创维盒子/双子星云手机.xcodeproj/project.pbxproj

+ 22 - 0
创维盒子/code/Assets.xcassets/NAS/uploadFile_file_bigger.imageset/Contents.json

@@ -0,0 +1,22 @@
+{
+  "images" : [
+    {
+      "idiom" : "universal",
+      "scale" : "1x"
+    },
+    {
+      "filename" : "uploadFile_file_bigger@2x.png",
+      "idiom" : "universal",
+      "scale" : "2x"
+    },
+    {
+      "filename" : "uploadFile_file_bigger@3x.png",
+      "idiom" : "universal",
+      "scale" : "3x"
+    }
+  ],
+  "info" : {
+    "author" : "xcode",
+    "version" : 1
+  }
+}

BIN
创维盒子/code/Assets.xcassets/NAS/uploadFile_file_bigger.imageset/uploadFile_file_bigger@2x.png


BIN
创维盒子/code/Assets.xcassets/NAS/uploadFile_file_bigger.imageset/uploadFile_file_bigger@3x.png


+ 5 - 5
创维盒子/code/Class/Set/previewFile/view/previewToUploadFileView.m

@@ -103,11 +103,12 @@
    
     
     NSArray *titleArr = @[NSLocalizedString(@"my_set_no_image_upload",nil),
-                          NSLocalizedString(@"my_set_no_video_upload",nil)];
+                          NSLocalizedString(@"my_set_no_video_upload",nil)
+                          ,NSLocalizedString(@"my_set_no_file",nil)];
   
     NSArray *imageStrArr = @[@"uploadFile_image_bigger",
                              @"uploadFile_Video_bigger"
-                             ];
+                             ,@"uploadFile_file_bigger"];
     
     CGFloat curButFullWidth = SCREEN_W/4.0;
     
@@ -180,11 +181,11 @@
         make.bottom.equalTo(whiteBgView.mas_top).offset(0);
         make.top.mas_equalTo(40);
     }];
-//    
+//
 //    UIView *lineView = [[UIView alloc] init];
 //    lineView.backgroundColor = [UIColor hwColor:@"#EAEAEA"];
 //    [whiteBgView addSubview:lineView];
-//    
+//
 //    [lineView mas_makeConstraints:^(MASConstraintMaker *make) {
 //        make.left.mas_equalTo(25);
 //        make.right.mas_equalTo(-25);
@@ -215,4 +216,3 @@
 }
 
 @end
-

+ 0 - 218
创维盒子/code/Class/Set/previewFile/view/previewToUploadFileView~.m

@@ -1,218 +0,0 @@
-//
-//  previewToUploadFileView.m
-//  双子星云手机
-//
-//  Created by xd h on 2024/5/14.
-//
-
-#import "previewToUploadFileView.h"
-
-@interface previewToUploadFileView ()
-
-@end
-
-@implementation previewToUploadFileView
-
-- (id)initWithFrame:(CGRect)frame{
-    self = [super initWithFrame:frame];
-    [self checkDidHadUploadTaskFun];
-    //[self drawAnyView];
-    return self;
-}
-
--(void)checkDidHadUploadTaskFun
-{
-  [[NSNotificationCenter defaultCenter] postNotificationName:getExtraFilesDoneNotification object:nil];/*发送通知*/
-    
-   KWeakSelf
-   [[nasUploadFileManager shareInstance] getDataInDatabaseFun:YES complete:^(NSMutableArray * _Nonnull Arr) {
-       mainBlock(^{
-           if(Arr && Arr.count== 3){
-               NSArray *uploadingArr = Arr.firstObject;
-               if(uploadingArr.count == 0){
-                   [weakSelf drawAnyView];
-               }
-               else{
-                   [[iToast makeText:NSLocalizedString(@"upload_task_not_done_tip",nil)] show];
-                   if(self->_didClickCloseFun){
-                       self->_didClickCloseFun();
-                   }
-                   [weakSelf removeFromSuperview];
-               }
-           }
-           else{
-               [weakSelf drawAnyView];
-           };
-       });
-           
-   }];
-}
-
-- (void)drawAnyView{
-    
-    self.backgroundColor = [UIColor hwColor:@"#000000" alpha:0.6];
-    
-    UIView *whiteBgView = [[UIView alloc] init];
-    whiteBgView.backgroundColor = [UIColor whiteColor];
-    [self addSubview:whiteBgView];
-//    whiteBgView.layer.cornerRadius = 12;
-//    whiteBgView.layer.masksToBounds = YES;
-    
-    /*上圆角*/
-    UIBezierPath *maskPath = [UIBezierPath bezierPathWithRoundedRect:CGRectMake(0, 0, SCREEN_W , 180+ AdaptTabHeight)
-                                                   byRoundingCorners:UIRectCornerTopLeft|UIRectCornerTopRight
-                                                         cornerRadii:CGSizeMake(12, 12)];
-    CAShapeLayer *maskLayer = [[CAShapeLayer alloc] init];
-    maskLayer.frame = CGRectMake(0, 0, SCREEN_W, 180+ AdaptTabHeight);
-    maskLayer.path = maskPath.CGPath;
-    whiteBgView.layer.mask = nil;
-    whiteBgView.layer.mask = maskLayer;
-    
-    
-    [whiteBgView mas_makeConstraints:^(MASConstraintMaker *make) {
-        make.left.mas_equalTo(0);
-        make.right.mas_equalTo(0);
-        make.bottom.mas_equalTo(0);
-        make.height.mas_equalTo(180+ AdaptTabHeight);
-    }];
-    
- 
-    UILabel *titleLabel = [[UILabel alloc] init];
-    titleLabel.font = [UIFont systemFontOfSize:18.0];
-    titleLabel.textColor = [UIColor hwColor:@"#0A132B" alpha:1.0];
-    [whiteBgView addSubview:titleLabel];
-    
-    NSString *leftText = NSLocalizedString(@"uploadFile_title_left",nil);
-    NSString *rightText = NSLocalizedString(@"uploadFile_title_right",nil);
-    NSString *totalStr = [[NSString alloc] initWithFormat:@"%@  %@",leftText,rightText];
-    
-    NSMutableAttributedString *attrStr = [[NSMutableAttributedString alloc] initWithString:totalStr];
-    NSRange redRange = NSMakeRange([totalStr rangeOfString:rightText].location, [totalStr rangeOfString:rightText].length);
-    UIColor *noteColor =[UIColor hwColor:@"#959799" alpha:1.0];
-    [attrStr addAttribute:NSForegroundColorAttributeName value:noteColor range:redRange];
-    [attrStr addAttribute:NSFontAttributeName value:[UIFont systemFontOfSize:12.0] range:redRange];
-    titleLabel.attributedText = attrStr;
-    
-    [titleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
-        make.left.mas_equalTo(25);
-        make.right.mas_equalTo(0);
-        make.top.mas_equalTo(20);
-        make.height.mas_equalTo(40);
-    }];
-    
-   
-    
-    NSArray *titleArr = @[NSLocalizedString(@"my_set_no_image_upload",nil),
-                          NSLocalizedString(@"my_set_no_video_upload",nil)];
-  
-    NSArray *imageStrArr = @[@"uploadFile_image_bigger",
-                             @"uploadFile_Video_bigger"
-                             ];
-    
-    CGFloat curButFullWidth = SCREEN_W/4.0;
-    
-    for (int i = 0; i< titleArr.count; i++) {
-
-        UIButton*curButton = [[UIButton alloc] init];
-        [curButton addTarget:self action:@selector(didClickButFun:) forControlEvents:UIControlEventTouchUpInside];
-        curButton.tag = 10+i;
-        [whiteBgView addSubview:curButton];
-
-        [curButton mas_makeConstraints:^(MASConstraintMaker *make) {
-            make.width.mas_equalTo(curButFullWidth);
-            make.left.mas_equalTo(i*curButFullWidth);
-            make.height.mas_equalTo(80);
-            make.top.equalTo(titleLabel.mas_bottom).offset(20);
-        }];
-        
-        UIView *imageBgView = [[UIView alloc] init];
-        imageBgView.userInteractionEnabled = NO;
-        imageBgView.backgroundColor = [UIColor hwColor:@"#F5F7FA"];
-        imageBgView.layer.cornerRadius = 8;
-        imageBgView.layer.masksToBounds = YES;
-        [curButton addSubview:imageBgView];
-        
-        [imageBgView mas_makeConstraints:^(MASConstraintMaker *make) {
-            make.width.mas_equalTo(64);
-            make.height.mas_equalTo(52);
-            make.centerX.equalTo(curButton.mas_centerX);
-            make.top.mas_equalTo(0);
-        }];
-        
-        UIImageView *leftImageV = [[UIImageView alloc] init];
-        leftImageV.image = [UIImage imageNamed:imageStrArr[i]];
-        [imageBgView addSubview:leftImageV];
-
-        [leftImageV mas_makeConstraints:^(MASConstraintMaker *make) {
-            make.width.mas_equalTo(35);
-            make.height.mas_equalTo(35);
-            make.centerX.equalTo(imageBgView.mas_centerX);
-            make.centerY.equalTo(imageBgView.mas_centerY).offset(0);
-        }];
-
-        UILabel *leftLabel = [[UILabel alloc] init];
-        leftLabel.textColor = [UIColor hwColor:@"#0A132B"];
-        leftLabel.textAlignment = NSTextAlignmentCenter;
-        leftLabel.font = [UIFont systemFontOfSize:12.0];
-        leftLabel.text = titleArr[i];
-        [curButton addSubview:leftLabel];
-
-        [leftLabel mas_makeConstraints:^(MASConstraintMaker *make) {
-            make.width.mas_equalTo(curButFullWidth);
-            make.height.mas_equalTo(25);
-            make.centerX.equalTo(curButton.mas_centerX);
-            make.top.equalTo(imageBgView.mas_bottom).offset(10);
-        }];
-    }
-    
-    
-    UIButton*cancelButton = [[UIButton alloc] init];
-    //[cancelButton setTitle:NSLocalizedString(@"other_cancel",nil) forState:UIControlStateNormal];
-    //[cancelButton setTitleColor:[UIColor hwColor:@"#0A132B"] forState:UIControlStateNormal];
-    [cancelButton addTarget:self action:@selector(didClickButFun:) forControlEvents:UIControlEventTouchUpInside];
-    //cancelButton.titleLabel.font = [UIFont boldSystemFontOfSize:14];
-    cancelButton.tag = 100;
-    [self addSubview:cancelButton];
-    
-    [cancelButton mas_makeConstraints:^(MASConstraintMaker *make) {
-        make.left.mas_equalTo(0);
-        make.right.mas_equalTo(0);
-        make.bottom.equalTo(whiteBgView.mas_top).offset(0);
-        make.top.mas_equalTo(40);
-    }];
-//    
-//    UIView *lineView = [[UIView alloc] init];
-//    lineView.backgroundColor = [UIColor hwColor:@"#EAEAEA"];
-//    [whiteBgView addSubview:lineView];
-//    
-//    [lineView mas_makeConstraints:^(MASConstraintMaker *make) {
-//        make.left.mas_equalTo(25);
-//        make.right.mas_equalTo(-25);
-//        make.bottom.equalTo(cancelButton.mas_top).offset(-5);
-//        make.height.mas_equalTo(1);
-//    }];
-    
-    //数据埋点
-    [[netWorkManager shareInstance] DataEmbeddingPointBy:2 withEventValue:@"Nas_upload"];
-}
-
-- (void)didClickButFun:(UIButton*)but
-{
-    [self removeFromSuperview];
-    
-    NSInteger tag = but.tag;
-    if(tag == 100)
-    {
-        if(_didClickCloseFun){
-            _didClickCloseFun();
-        }
-        return;
-    }
-    
-    if(_didClickButtonFun){
-        _didClickButtonFun(tag);
-    }
-}
-
-@end
-

+ 1 - 1
创维盒子/code/Class/Set/uploadFile/model/uploadFileDataModel.h

@@ -21,7 +21,7 @@ typedef enum{
 typedef enum{
     uploadFileTypeImage = 0,
     uploadFileTypeVideo,
-    uploadFileTypeUnkonw,
+    uploadFileTypeFileAPP,//(文件APP里的文件)
     DownLoadThumbnail,//下载缩略图
     DownLoadFileType,//下载文件
 }uploadFileType;

+ 4 - 0
创维盒子/code/Class/Set/uploadFile/uploadFileManager/cachesFileManager.h

@@ -13,6 +13,10 @@
 #define kSHPath_image [cachesFileManager getCreateFilePath:[NSString stringWithFormat:@"%@/Image",CachesPatch]]
 //视频路径
 #define kSHPath_video [cachesFileManager getCreateFilePath:[NSString stringWithFormat:@"%@/Video",CachesPatch]]
+
+//从文件APP中 拷贝到app里面
+#define kSHPath_FileAPP [cachesFileManager getCreateFilePath:[NSString stringWithFormat:@"%@/FileApp",CachesPatch]]
+
 //下载缩略图 图片 DownLoadThumbnail
 #define kSHPath_DownLoadThumbnail [cachesFileManager getCreateFilePath:[NSString stringWithFormat:@"%@/DownLoadThumbnail",CachesPatch]]
 

+ 5 - 0
创维盒子/code/Class/Set/uploadFile/uploadFileManager/cachesFileManager.m

@@ -132,6 +132,11 @@
             name = [NSString stringWithFormat:@"%@/%@",kSHPath_video,name];
         }
             break;
+        case uploadFileTypeFileAPP://文件APP
+        {
+            name = [NSString stringWithFormat:@"%@/%@",kSHPath_FileAPP,name];
+        }
+            break;
         case DownLoadThumbnail://image
         {
             name = [NSString stringWithFormat:@"%@/%@.png",kSHPath_DownLoadThumbnail,name];

+ 3 - 0
创维盒子/code/Class/Set/uploadFile/uploadFileRecordViewController.h

@@ -18,7 +18,10 @@ NS_ASSUME_NONNULL_BEGIN
 @interface uploadFileRecordViewController : BaseViewController
 //
 @property (nonatomic, assign) BOOL isUploadingType;//上传页面进入
+//处理相册的 图片或者视频
 -(void)gotoUploadFile:(NSMutableArray*)indexPathsForSelectedItems;
+//处理文件app上传的文件
+-(void)gotoUploadFileByFileApp:(NSArray*)FileUrl;
 
 @property (nonatomic, assign) BOOL isDownloadingType;//下载页面进入
 -(void)gotoDownloadFile:(NSMutableArray*)selectedItems;

+ 28 - 0
创维盒子/code/Class/Set/uploadFile/uploadFileRecordViewController.m

@@ -600,6 +600,34 @@
     }];
 }
 
+//处理文件app上传的文件
+-(void)gotoUploadFileByFileApp:(NSArray*)FileUrls{
+    
+    KWeakSelf
+    mainBlock(^{
+        weakSelf.didGetUploadDataType = YES;
+        [weakSelf handleRemoveIndicator];
+    });
+    
+    [self realGotoUploadFileByFileApp:FileUrls];
+}
+
+- (void)realGotoUploadFileByFileApp:(NSArray *)URLArr
+{
+    KWeakSelf
+    [[nasUploadFileManager shareInstance] handlUrlToUploadFileDataFunBy:URLArr complete:^(NSMutableArray * _Nonnull Arr) {
+        //NSMutableArray *arr1 = Arr;
+        //[weakSelf setRecordBodyDataFunBy:arr1];
+        
+        //weakSelf.leftTableView.curDataArr = Arr[0];
+        mainBlock(^{
+            weakSelf.leftTableView.outSideDataArr = Arr;
+            [weakSelf handleUploadingRightButFun:YES];
+        });
+        
+    }];
+}
+
 #pragma mark 读取数据库数据
 - (void)getUploadDataInDatabaseFun
 {

+ 4 - 1
创维盒子/code/Class/Set/uploadFile/uploadFileView/uploadFileRecordCell.m

@@ -262,7 +262,7 @@
                 }
             }
         }
-        else{
+        else if(curUploadFileDataModel.curUploadFileType == uploadFileTypeVideo){
             NSString*pathStr = [cachesFileManager getFilePathWithName:curUploadFileDataModel.videoFirstImageName type:uploadFileTypeImage];
              UIImage *image = [UIImage imageWithContentsOfFile:pathStr];
             
@@ -293,6 +293,9 @@
                 }];
             }
         }
+        else{//文件APP
+            _fileImageView.image = [UIImage imageNamed:@"uploadFile_other"];
+        }
     }
     
     

+ 3 - 0
创维盒子/code/Helpers/iTools.h

@@ -192,6 +192,9 @@ NS_ASSUME_NONNULL_BEGIN
 
 //传输用的路径换成显示的路径
 + (NSString *)changePathToShowPathBy:(NSString*)path;
+
+//获取文件大小
++ (unsigned long long)getFileSize:(NSString *)filePath;
 @end
 
 NS_ASSUME_NONNULL_END

+ 25 - 0
创维盒子/code/Helpers/iTools.m

@@ -1456,4 +1456,29 @@ static const char encodingTable[] = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopq
     
     return path;
 }
+
+//获取文件大小
++ (unsigned long long)getFileSize:(NSString *)filePath
+{
+    NSFileManager *fileManager = [NSFileManager defaultManager];
+    
+    // 检查文件是否存在
+    if ([fileManager fileExistsAtPath:filePath]) {
+        // 获取文件属性
+        NSError *error = nil;
+        NSDictionary *attributes = [fileManager attributesOfItemAtPath:filePath error:&error];
+        
+        if (error) {
+            HLog(@"Error getting file attributes: %@", error.localizedDescription);
+            return 0;
+        }
+        
+        // 返回文件大小
+        return [attributes fileSize];
+    } else {
+        HLog(@"File does not exist at path: %@", filePath);
+        return 0;
+    }
+}
+
 @end

+ 24 - 0
创维盒子/code/NAS/DocumentPickerManager/DocumentPickerManager.h

@@ -0,0 +1,24 @@
+//
+//  DocumentPickerManager.h
+//  隐私保护
+//
+//  Created by xd h on 2025/3/21.
+//
+
+#import <Foundation/Foundation.h>
+
+NS_ASSUME_NONNULL_BEGIN
+
+/**
+ *  成功请求Block返回的字典
+ */
+typedef void (^pickerSuccess) (NSArray* urls);
+
+@interface DocumentPickerManager : NSObject
+/** 实例化对象(单例) */
++ (instancetype)shareManager;
+
+- (void)openDocumentPickerSuccess:(pickerSuccess)success;
+@end
+
+NS_ASSUME_NONNULL_END

+ 131 - 0
创维盒子/code/NAS/DocumentPickerManager/DocumentPickerManager.m

@@ -0,0 +1,131 @@
+//
+//  DocumentPickerManager.m
+//  隐私保护
+//
+//  Created by xd h on 2025/3/21.
+//
+
+#import "DocumentPickerManager.h"
+#import <UIKit/UIKit.h>
+#import <MobileCoreServices/MobileCoreServices.h>
+
+@interface DocumentPickerManager () <UIDocumentPickerDelegate>
+{
+    NSArray *curURLS;
+    NSInteger PickerTotalNumber;//用户选择的数目
+    NSInteger didPickerOkNumber;//拷贝到APP内成功的数量
+    NSInteger didPickerFailNumber;//拷贝到APP内失败的数量
+}
+
+@property (nonatomic,copy) pickerSuccess didPickSuc;
+@end
+
+@implementation DocumentPickerManager
++ (instancetype)shareManager {
+    static DocumentPickerManager *_instance;
+    static dispatch_once_t onceToken;
+    dispatch_once(&onceToken, ^{
+        _instance = [[self alloc] init];
+    });
+    return _instance;
+}
+
+
+- (void)openDocumentPickerSuccess:(pickerSuccess)success {
+    
+    PickerTotalNumber = 0;
+    didPickerOkNumber = 0;
+    didPickerFailNumber = 0;
+    
+    _didPickSuc = success;
+    
+    // 创建 UIDocumentPickerViewController
+    UIDocumentPickerViewController *documentPicker = [[UIDocumentPickerViewController alloc] initWithDocumentTypes:@[(NSString *)kUTTypeItem] inMode:UIDocumentPickerModeImport];
+    
+    // 启用多选
+    documentPicker.allowsMultipleSelection = YES;
+    // 设置代理
+    documentPicker.delegate = self;
+    
+    // 设置模态呈现样式
+    documentPicker.modalPresentationStyle = UIModalPresentationFormSheet;
+    
+    // 弹出文档选择器
+    UIViewController* vc = [iTools appRootViewController];
+    [vc presentViewController:documentPicker animated:YES completion:nil];
+}
+
+#pragma mark - UIDocumentPickerDelegate
+
+- (void)documentPicker:(UIDocumentPickerViewController *)controller didPickDocumentsAtURLs:(NSArray<NSURL *> *)urls {
+    
+    PickerTotalNumber = urls.count;
+    curURLS = urls;
+    for (NSURL *fileURL in urls) {
+        // 将文件保存到应用的沙盒目录
+        [self saveFileToAppSandbox:fileURL];
+    }
+}
+
+- (void)documentPickerWasCancelled:(UIDocumentPickerViewController *)controller {
+    // 用户取消了文件选择
+    HLog(@"Document picker was cancelled");
+}
+
+- (void)saveFileToAppSandbox:(NSURL *)fileURL {
+    // 获取文件名称
+    NSString *fileName = [fileURL lastPathComponent];
+    
+    // 获取应用的 Documents 目录路径
+//    NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
+//    NSString *documentsDirectory = [paths firstObject];
+    
+    NSString *documentsDirectory = kSHPath_FileAPP;
+    
+    // 构建目标文件路径
+    NSString *destinationPath = [documentsDirectory stringByAppendingPathComponent:fileName];
+    NSURL *destinationURL = [NSURL fileURLWithPath:destinationPath];
+    
+    // 检查文件是否已经存在
+    if ([[NSFileManager defaultManager] fileExistsAtPath:destinationPath]) {
+        HLog(@"文件已存在: %@", destinationPath);
+        didPickerOkNumber ++;
+        [self didFinishPickerTaskFun];
+        return;
+    }
+    
+    // 将文件从临时位置复制到目标路径
+    KWeakSelf
+    dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
+        NSError *error;
+        BOOL success = [[NSFileManager defaultManager] copyItemAtURL:fileURL toURL:destinationURL error:&error];
+        
+        if (success) {
+            HLog(@"文件保存成功: %@", destinationPath);
+            self->didPickerOkNumber ++;
+        } else {
+            HLog(@"文件保存失败: %@", error.localizedDescription);
+            self->didPickerFailNumber ++;
+        }
+        
+        mainBlock(^{
+            [weakSelf didFinishPickerTaskFun];
+        });
+        
+    });
+}
+
+#pragma mark 判断是否处理完成数据
+- (void)didFinishPickerTaskFun
+{
+    if (didPickerOkNumber + didPickerFailNumber < PickerTotalNumber ) {
+        return;
+    }
+    
+    HLog(@"处理完成了")
+    
+    if(_didPickSuc){
+        _didPickSuc(curURLS);
+    }
+}
+@end

+ 23 - 5
创维盒子/code/NAS/NASViewController.m

@@ -42,6 +42,7 @@
 #import "imageVersionUpdateFailView.h"
 #import "queryHeartbeatModel.h"
 #import "BoxHeartbeatAlertTool.h"
+#import "DocumentPickerManager.h"
 
 @interface NASViewController ()<UITableViewDelegate,UITableViewDataSource>
 {
@@ -645,14 +646,22 @@
 #pragma mark 调整文件上传
 - (void)gotoUploadFileFunWith:(NSInteger)tag
 {
-    uploadImageOrVideoViewController *vc = [uploadImageOrVideoViewController new];
-    if(tag ==10){
-        vc.isPhotoType = YES;
+    if(tag == 10 || tag == 11){
+        uploadImageOrVideoViewController *vc = [uploadImageOrVideoViewController new];
+        if(tag ==10){
+            vc.isPhotoType = YES;
+        }
+        else{
+            vc.isPhotoType = NO;
+        }
+        [self pushViewController:vc animated:YES];
     }
     else{
-        vc.isPhotoType = NO;
+        KWeakSelf
+        [[DocumentPickerManager shareManager] openDocumentPickerSuccess:^(NSArray * _Nonnull urls) {
+            [weakSelf gotoUploadFileRecordByFileAppWithUrls:urls];
+        }];
     }
-    [self pushViewController:vc animated:YES];
 }
 
 #pragma mark 获取到云机磁盘相关信息
@@ -1099,4 +1108,13 @@
     });
 }
 
+#pragma mark 文件上传跳转上传记录
+- (void)gotoUploadFileRecordByFileAppWithUrls:(NSArray*)urls
+{
+    uploadFileRecordViewController *vc = [uploadFileRecordViewController new];
+    [self.navigationController pushViewController:vc animated:YES];
+    vc.isUploadingType = YES;
+    [vc gotoUploadFileByFileApp:urls];
+    
+}
 @end

+ 47 - 7
创维盒子/code/NAS/nasUploadManager/nasMixUploadManager.m

@@ -51,7 +51,15 @@
         
         //1. 排查上传中
         for (customUploadOperation *operationDoing in self.uploadingOperationArr) {
-            if([operationDoing.fileModel.localIdentifier isEqualToString:model.localIdentifier]){
+            if(operationDoing.fileModel.localIdentifier && [operationDoing.fileModel.localIdentifier isEqualToString:model.localIdentifier]){
+                needAddType = NO;
+                break;
+            }
+            
+            //文件APP上传处理
+            if (model.curUploadFileType == uploadFileTypeFileAPP
+                && operationDoing.fileModel.curUploadFileType == uploadFileTypeFileAPP
+                && [operationDoing.fileModel.filename isEqualToString:model.filename]) {
                 needAddType = NO;
                 break;
             }
@@ -59,7 +67,15 @@
         
         //1. 排查等待下载
         for (uploadFileDataModel *waitModel in self.uploadWaitingUrlArr) {
-            if([waitModel.localIdentifier isEqualToString:model.localIdentifier]){
+            if(waitModel.localIdentifier && [waitModel.localIdentifier isEqualToString:model.localIdentifier]){
+                needAddType = NO;
+                break;
+            }
+            
+            //文件APP上传处理
+            if (waitModel.curUploadFileType == uploadFileTypeFileAPP
+                && model.curUploadFileType == uploadFileTypeFileAPP
+                && [waitModel.filename isEqualToString:model.filename]) {
                 needAddType = NO;
                 break;
             }
@@ -273,13 +289,13 @@
 //    mainBlock(^{
 //        [[iToast makeText:NSLocalizedString(@"File_upload_file_already_exists",nil)] show];
 //    });
-//    
+//
 //    NSMutableArray *delArr = [NSMutableArray new];
 //    [delArr addObject:operation.fileModel];
-//    
+//
 //    [[nasUploadFileManager shareInstance] deleteUploadFileRecordBy:delArr withDelCache:YES complete:^(BOOL isSuccess) {
 //        if (isSuccess) {
-//            
+//
 //        }
 //    }];
     
@@ -403,7 +419,7 @@
             [weakSelf handleUploadFailOneFileBy:operation];
         }];
     }
-    else{
+    else if(operation.fileModel.curUploadFileType == uploadFileTypeVideo){
         [paraDict setObject:@1 forKey:@"videoType"];
         [paraDict setObject:@"false" forKey:@"isLast"];
 
@@ -449,10 +465,28 @@
             
         }];
     }
+    else if(operation.fileModel.curUploadFileType == uploadFileTypeFileAPP){
+        //上传文件
+        [paraDict setObject:@3 forKey:@"videoType"];
+        [paraDict setObject:@"false" forKey:@"isLast"];
+
+        if(![cachesFileManager checkFileIsSaveState:operation.fileModel.filename withType:uploadFileTypeFileAPP]){
+            
+            [weakSelf handleUploadFailOneFileBy:operation];
+            return;
+        }
+        
+        long curPosition = operation.fileModel.didUploadBytes;
+        [self beginUploadVideoDataFunBy:operation with:curPosition withPara:paraDict success:^(id  _Nonnull responseObject) {
+            
+        } faild:^(NSError * _Nonnull error) {
+            
+        }];
+    }
     
 }
 
-#pragma mark 视频上传
+#pragma mark 视频上传 或者文件APP上传
 - (void)beginUploadVideoDataFunBy:(customUploadOperation*)operation with:(NSInteger)position withPara:(NSMutableDictionary*)paraDict success:(netWork_Success)success faild:(netWork_Faild)faildStr
 {
     if(operation.isCancelType){
@@ -515,8 +549,14 @@
     
     HLog(@"视频切片开始 线程:%@",[NSThread currentThread]);
     
+    //视频
     NSString *filePath = [cachesFileManager getFilePathWithName:dataModel.filename type:uploadFileTypeVideo]; // 文件路径
     
+    //文件APP
+    if (dataModel.curUploadFileType == uploadFileTypeFileAPP) {
+        filePath = [cachesFileManager getFilePathWithName:dataModel.filename type:uploadFileTypeFileAPP]; // 文件路径
+    }
+    
     NSFileManager *manager0 = [NSFileManager defaultManager];
     if(![manager0 fileExistsAtPath:filePath]) {
      

+ 0 - 987
创维盒子/code/NAS/nasUploadManager/nasMixUploadManager~.m

@@ -1,987 +0,0 @@
-//
-//  nasMixUploadManager.m
-//  双子星云手机
-//
-//  Created by xd h on 2024/8/27.
-//
-
-#import "nasMixUploadManager.h"
-#import "customUploadOperation.h"
-#import "nasUploadFileManager.h"
-#import "frpFileExistModel.h"
-#import "frpUploadModel.h"
-
-#define Kboundary2 @"Boundaryhxd"
-
-@interface nasMixUploadManager ()<NSURLSessionDataDelegate>
-//排队等候下载的上传地址数组
-@property(nonatomic,strong) NSMutableArray *uploadWaitingUrlArr;
-//正在下载的上传地址数组
-@property(nonatomic,strong) NSMutableArray *uploadingOperationArr;
-
-@end
-
-@implementation nasMixUploadManager
-+ (instancetype)shareManager {
-    static nasMixUploadManager *_instance;
-    static dispatch_once_t onceToken;
-    dispatch_once(&onceToken, ^{
-        _instance = [[self alloc] init];
-    });
-    return _instance;
-}
-
-- (instancetype)init {
-
-    if (self = [super init]) {
-        _maxUploadLoadCount = 2;
-        
-        //[self registeNotification];
-    }
-    return self;
-}
-
-/** 添加要上传的 模型  */
-- (void)addUploadWithModels:(NSArray *)fileModels{
-    
-    HLog(@"添加任务-- %ld",fileModels.count)
-    
-    for (uploadFileDataModel *model in fileModels) {
-        BOOL needAddType = YES;
-        
-        //1. 排查上传中
-        for (customUploadOperation *operationDoing in self.uploadingOperationArr) {
-            if([operationDoing.fileModel.localIdentifier isEqualToString:model.localIdentifier]){
-                needAddType = NO;
-                break;
-            }
-        }
-        
-        //1. 排查等待下载
-        for (uploadFileDataModel *waitModel in self.uploadWaitingUrlArr) {
-            if([waitModel.localIdentifier isEqualToString:model.localIdentifier]){
-                needAddType = NO;
-                break;
-            }
-        }
-        
-        if(needAddType){
-            [self.uploadWaitingUrlArr addObject:model];
-        }
-    }
-    
-    //启动上传
-    [self beginUploadAfterDeleteOperationBy:nil];
-}
-
-//在添加XX后 启动下载
-- (void)beginUploadAfterDeleteOperationBy:(customUploadOperation*)operation
-{
-    HLog(@"beginUploadAfterDeleteOperationBy")
-    BOOL isCanUseCellular = [HWDataManager getBoolWithKey:stringKeyAddSn(Const_file_Transfe_canUse_Cellular_all)];
-    if(!isCanUseCellular){//不允许流量上传
-        //
-        if([AFNetworkReachabilityManager sharedManager].networkReachabilityStatus == AFNetworkReachabilityStatusReachableViaWWAN){
-            mainBlock(^{
-                //[[NSNotificationCenter defaultCenter] postNotificationName:uploadFileSuspendAllNotification object:nil];
-                [[iToast makeText:NSLocalizedString(@"File_Transfer_By_Cellular_tip",nil)] show];
-            });
-            return;
-        }
-        
-    }
-    
-    if(ksharedAppDelegate.DisabledFileTransferType){
-        if(ksharedAppDelegate.isImageNewFor130){
-            [[iToast makeText:NSLocalizedString(@"File_Transfer_Disable_tip",nil)] show];
-        }
-        else{
-            [[iToast makeText:NSLocalizedString(@"File_Transfer_Disable_tip2",nil)] show];
-        }
-        return;
-    }
-    
-    
-    if(operation){
-        HLog(@"删除完成的上传任务")
-        
-//        if([operation.fileModel.filename isEqualToString:@"IMG_8876.PNG"]){
-//            HLog(@"uploadWaitingUrlArr -- count:%ld",self.uploadWaitingUrlArr.count)
-//            for(uploadFileDataModel*model in self.uploadWaitingUrlArr){
-//                HLog(@"fileName--%@--%ld",model.filename,model.totalBytes)
-//            }
-//        }
-        
-        @synchronized (self) {
-            if(operation.fileHandle){
-                [operation closeFileHandleFun];
-            }
-            [self.uploadingOperationArr removeObject:operation];
-        }
-    }
-    
-    if(self.uploadingOperationArr.count == _maxUploadLoadCount){
-        HLog(@"正在上传的数量达到了最大值 %ld",_maxUploadLoadCount)
-        return;
-    }
-    
-    if(self.uploadWaitingUrlArr.count == 0){
-        HLog(@"没有等待中的上传任务")
-        return;
-    }
-    
-    NSInteger canAddTaskNumber = _maxUploadLoadCount - self.uploadingOperationArr.count;
-    
-    //新添加的任务
-    NSMutableArray *newTaskArr = [NSMutableArray new];
-    
-    @synchronized (self) {
-        for (int i=0; i<canAddTaskNumber; i++) {
-            
-            if(self.uploadWaitingUrlArr.count >= 1){
-                //创建上传任务
-                uploadFileDataModel *WaitingModel = self.uploadWaitingUrlArr.firstObject;
-                
-                customUploadOperation * operation =  [customUploadOperation new];
-                operation.fileModel = WaitingModel;
-                
-                //等待下载中的任务
-                [self.uploadWaitingUrlArr removeObjectAtIndex:0];
-                
-                HLog(@"添加一个新的上传任务 %@",self.uploadingOperationArr)
-                //添加到下载中数组
-                [self.uploadingOperationArr addObject:operation];
-                
-                //[self checkFileUploadStateWithOperation:operation];
-                
-                [newTaskArr addObject:operation];
-                
-                //[weakSelf handleTaskDidUploadWith:operation withState:state];
-            }
-            
-        }
-        
-        //开始检测新的上传任务
-        for (customUploadOperation * operation  in newTaskArr) {
-            [self checkFileUploadStateWithOperation:operation];
-        }
-        
-        [newTaskArr removeAllObjects];
-        
-    }
-    
-}
-
-#pragma mark 检测文件是否上传过了
-- (void)checkFileUploadStateWithOperation:(customUploadOperation*)operation
-{
-    HLog(@"%@检测文件是否过--%ld",operation.fileModel.filename,operation.fileModel.totalBytes)
-    
-    NSMutableDictionary*paraDict = [NSMutableDictionary new];
-    
-    //operation.fileModel.filename = @"Img_4107.png";// test same name file
-    if(operation.fileModel.savePath){
-        NSString *absPath = [[NSString alloc] initWithFormat:@"%@%@",operation.fileModel.savePath,operation.fileModel.filename];
-        [paraDict setValue:absPath forKey:@"absPath"];
-        
-        NSNumber *totalBytesNumber = [NSNumber numberWithLong:operation.fileModel.totalBytes];
-        [paraDict setValue:totalBytesNumber forKey:@"fileSize"];
-    }
-    
-    KWeakSelf
-    [[netWorkManager shareInstance] cloudPhoneGETCallBackCode:@"isFileExist" Parameters:paraDict success:^(id  _Nonnull responseObject) {
-        
-        frpFileExistModel *model = [[frpFileExistModel alloc] initWithDictionary:responseObject error:nil];
-        if(model && model.status == 0){
-            [weakSelf checkFileUploadStateFunAfterNetWith:model WithOperation:operation];
-        }
-        else if(model && model.status == 5){//云机空间不足
-            //上传路径
-            NSString * backupsDefaultPath = [HWDataManager getStringWithKey:stringKeyAddSn(Const_photo_upload_default_path)];
-            NSArray * stringArr = [backupsDefaultPath componentsSeparatedByString:@"/"];
-            NSString *lastStr = stringArr.lastObject;
-            NSString *repStr = [[NSString alloc] initWithFormat:@"/%@",lastStr];
-            NSString *name = [backupsDefaultPath stringByReplacingOccurrencesOfString:repStr withString:@""];
-            name = [iTools changePathToShowPathBy:name];
-            
-            NSString* showTip = [[NSString alloc] initWithFormat:@"【%@】%@",name,NSLocalizedString(@"disk_space_not_tip_for_95",nil)];
-            [[iToast makeText:showTip] show];
-            
-            [weakSelf handleUploadFailOneFileBy:operation];
-        }
-        else{
-            HLog(@"isFileExist接口异常:%@",responseObject)
-            [weakSelf handleUploadFailOneFileBy:operation];
-        }
-    } failure:^(NSError * _Nonnull error) {
-        HLog(@"%@",error)
-        [weakSelf handleUploadFailOneFileBy:operation];
-    }];
-    
-}
-
-#pragma mark 检测分家是否存在后处理 是否要上传
-- (void)checkFileUploadStateFunAfterNetWith:(frpFileExistModel*)model WithOperation:(customUploadOperation*)operation
-{
-    if(!model){
-        [self handleUploadFailOneFileBy:operation];
-        return;
-    }
-    
-    operation.fileModel.didUploadBytes = 0;
-    operation.fileModel.taskId = model.data.fileTaskId;
-    
-    if(!model.data.exist){//未上传过
-        HLog(@"%@检测到文件未上传过--%ld",operation.fileModel.filename,operation.fileModel.totalBytes)
-        [self prepareToUploadFileWithOperation:operation];
-    }
-    else if(model.data.isComplete){//上传过了 并且文件上传完了
-        //判断下文件创建长度是否一致 一致则是上传完了 不一致 重新上传一个 可能是同名的文件而已
-//        if(model.data.size >= operation.fileModel.totalBytes){//上传完了
-//            [self handleFileDidUploadFunWithOperation:operation];
-//        }
-//        else{//未上传完 isComplete 这个字段有问题
-//            operation.fileModel.didUploadBytes = model.data.size;
-//            [self prepareToUploadFileWithOperation:operation];
-//        }
-        
-        HLog(@"%@检测到文件上传完成--%ld",operation.fileModel.filename,operation.fileModel.totalBytes)
-        
-        //修复同名文件丢失问题
-        if(model.data.size == operation.fileModel.totalBytes){//上传完了
-            HLog(@"1111111")
-            [self handleFileDidUploadFunWithOperation:operation];
-        }
-        else{//同名文件 处理
-            HLog(@"2222222")
-            [self prepareToUploadFileWithOperation:operation];
-        }
-        
-    }
-    else{//上传过了 未上传完成
-        HLog(@"%@检测到文件上传过了 未上传完成--%ld",operation.fileModel.filename,operation.fileModel.totalBytes)
-        
-        operation.fileModel.didUploadBytes = model.data.size;
-        [self prepareToUploadFileWithOperation:operation];
-    }
-}
-
-
-#pragma mark 任务上传过了了
-- (void)handleFileDidUploadFunWithOperation:(customUploadOperation*)operation
-{
-//    mainBlock(^{
-//        [[iToast makeText:NSLocalizedString(@"File_upload_file_already_exists",nil)] show];
-//    });
-//    
-//    NSMutableArray *delArr = [NSMutableArray new];
-//    [delArr addObject:operation.fileModel];
-//    
-//    [[nasUploadFileManager shareInstance] deleteUploadFileRecordBy:delArr withDelCache:YES complete:^(BOOL isSuccess) {
-//        if (isSuccess) {
-//            
-//        }
-//    }];
-    
-    //改为走上传完成的逻辑
-    [self handleUploadDoneOneFileBy:operation];
-}
-
-//加个接口 做删除用的
-- (void)deleteUploadFileRecordWithOperation:(customUploadOperation*)operation{
-    NSMutableArray *delArr = [NSMutableArray new];
-    [delArr addObject:operation.fileModel];
-    
-    [[nasUploadFileManager shareInstance] deleteUploadFileRecordBy:delArr withDelCache:YES complete:^(BOOL isSuccess) {
-        if (isSuccess) {
-            
-        }
-    }];
-}
-
-
-#pragma mark 准备上传文件
-- (void)prepareToUploadFileWithOperation:(customUploadOperation*)operation
-{
-    NSMutableDictionary *paraDict = [NSMutableDictionary new];
-    
-    NSString* taskUid  = operation.fileModel.taskId;
-    if(!taskUid || taskUid.length == 0){
-        taskUid = [iTools getTaskUidStr];
-        operation.fileModel.taskId = taskUid;
-    }
-    
-    [paraDict setObject:taskUid forKey:@"taskId"];
-    [paraDict setObject:@0 forKey:@"position"];
-    [paraDict setObject:@"true" forKey:@"isLast"];
-    if(operation.fileModel.savePath){
-        [paraDict setObject:operation.fileModel.savePath forKey:@"savePath"];
-    }
-    else{
-        HLog(@"获取保存路径失败")
-        [self handleUploadFailOneFileBy:operation];
-        return;
-    }
-    
-    if(operation.fileModel.filename){
-        [paraDict setObject:operation.fileModel.filename forKey:@"filename"];
-    }
-    else{
-        HLog(@"获取用户名失败")
-        return;
-    }
-    
-    KWeakSelf
-    if(operation.fileModel.curUploadFileType == uploadFileTypeImage){
-        [paraDict setObject:@1 forKey:@"imageType"];
-        
-        if(!operation.fileModel.imageData){
-            
-            NSString*pathStr = [cachesFileManager getFilePathWithName:operation.fileModel.filename type:operation.fileModel.curUploadFileType];
-            NSData *imageData = [NSData dataWithContentsOfFile:pathStr];
-            
-            //修复出现过 图片数据小于totalBytes
-            if(imageData){
-                long curDataLengt = [imageData length];
-                if(curDataLengt == operation.fileModel.didUploadBytes && curDataLengt < operation.fileModel.totalBytes){
-                    HLog(@"totalBytes 获取出错?")
-                    [self deleteUploadFileRecordWithOperation:operation];
-                    return;
-                }
-            }
-            
-            if (!imageData) {
-                
-                if(!operation.fileModel.asset){
-                    NSString *curLocalIdentifier = operation.fileModel.localIdentifier;
-                    PHFetchResult *fetchResult = [PHAsset fetchAssetsWithLocalIdentifiers:@[curLocalIdentifier] options:nil];
-                    PHAsset *asset = fetchResult.firstObject;
-                    operation.fileModel.asset = asset;
-                }
-                
-                [[PHImageManager defaultManager] requestImageDataForAsset:operation.fileModel.asset options:nil resultHandler:^(NSData * _Nullable imageData, NSString * _Nullable dataUTI, UIImageOrientation orientation, NSDictionary * _Nullable info) {
-                        // 直接得到最终的 NSData 数据
-                        if (imageData) {
-                            operation.fileModel.imageData = imageData;
-                            if(operation.fileModel.totalBytes == 0){
-                                operation.fileModel.totalBytes = [imageData length];
-                            }
-                            [weakSelf  afterGetImageDataFunWithOperation:operation];
-                        }
-                        else{
-                            HLog(@"\n\n\n\nrequestImageDataForAsset fail imageData nil\n\n\n")
-                            [weakSelf handleUploadFailOneFileBy:operation];
-                        }
-                }];
-                return;
-            }
-            
-            operation.fileModel.imageData = imageData;
-        }
-        
-        HLog(@"%@开始上传--%ld",operation.fileModel.filename,operation.fileModel.totalBytes)
-        
-        NSData *curData = operation.fileModel.imageData;
-        operation.onceDataLengt = [curData length];
-        
-        if(operation.fileModel.totalBytes == 0){//异常处理
-            operation.fileModel.totalBytes = operation.onceDataLengt;
-        }
-        
-        [self startUpload:paraDict operation:operation data:curData success:^(id  _Nonnull responseObject) {
-            frpUploadModel *model = [[frpUploadModel alloc] initWithDictionary:responseObject error:nil];
-            if(model && model.position == operation.fileModel.totalBytes && model.position != 0){
-                HLog(@"%@上传完成 000---%ld",operation.fileModel.filename,operation.fileModel.totalBytes)
-                [weakSelf handleUploadDoneOneFileBy:operation];
-            }
-            else{
-                HLog(@"%@上传完成异常 %ld---%ld",operation.fileModel.filename,model.position,operation.fileModel.totalBytes)
-                [weakSelf handleUploadDoneOneFileBy:operation];
-            }
-        } faild:^(NSError * _Nonnull error) {
-            HLog(@"%@上传失败",operation.fileModel.filename)
-            [weakSelf handleUploadFailOneFileBy:operation];
-        }];
-    }
-    else{
-        [paraDict setObject:@1 forKey:@"videoType"];
-        [paraDict setObject:@"false" forKey:@"isLast"];
-
-        if(![cachesFileManager checkFileIsSaveState:operation.fileModel.filename withType:uploadFileTypeVideo]){
-            
-            if(!operation.fileModel.asset){
-                NSString *curLocalIdentifier = operation.fileModel.localIdentifier;
-                PHFetchResult *fetchResult = [PHAsset fetchAssetsWithLocalIdentifiers:@[curLocalIdentifier] options:nil];
-                PHAsset *asset = fetchResult.firstObject;
-                operation.fileModel.asset = asset;
-            }
-            
-
-            //真正的视频数据
-            PHVideoRequestOptions *options = [[PHVideoRequestOptions alloc] init];
-            options.version = PHVideoRequestOptionsVersionOriginal;
-            [[PHImageManager defaultManager] requestAVAssetForVideo:operation.fileModel.asset options:options resultHandler:^(AVAsset *asset, AVAudioMix *audioMix, NSDictionary *info) {
-                if ([asset isKindOfClass:[AVURLAsset class]]) {
-                    
-                    AVURLAsset* urlAsset = (AVURLAsset*)asset;
-                    
-                    BOOL isSuc = [cachesFileManager copyVideoItemAtPath:[urlAsset.URL path] fileName:operation.fileModel.filename error:nil];
-                    
-                    if (isSuc) {
-                        [weakSelf  afterGetVideoDataFunWithOperation:operation];
-                    }
-                    else{
-                        [weakSelf handleUploadFailOneFileBy:operation];
-                    }
-                }
-                else{
-                    [weakSelf handleUploadFailOneFileBy:operation];
-                }
-            }];
-            
-            return;
-        }
-        
-        long curPosition = operation.fileModel.didUploadBytes;
-        [self beginUploadVideoDataFunBy:operation with:curPosition withPara:paraDict success:^(id  _Nonnull responseObject) {
-            
-        } faild:^(NSError * _Nonnull error) {
-            
-        }];
-    }
-    
-}
-
-#pragma mark 视频上传
-- (void)beginUploadVideoDataFunBy:(customUploadOperation*)operation with:(NSInteger)position withPara:(NSMutableDictionary*)paraDict success:(netWork_Success)success faild:(netWork_Faild)faildStr
-{
-    if(operation.isCancelType){
-        HLog(@"防止取消不了任务生效")
-        return;
-    }
-    
-    BOOL isLastPicece = NO;
-    if((operation.fileModel.totalBytes - position) <= MaxNasUploadPieceSzie){
-        [paraDict setObject:@"true" forKey:@"isLast"];
-        isLastPicece = YES;
-    }
-    else{
-        [paraDict setObject:@"false" forKey:@"isLast"];
-    }
-    
-    [paraDict setObject:[NSNumber numberWithLong:position] forKey:@"position"];
-    
-    //视频数据切片
-    __block NSData *videoData = [self cutVideoFileFunAtIndex:position withMaxLenght:MaxNasUploadPieceSzie withModel:operation.fileModel withOperation:operation];
-    
-    if(!videoData ||videoData.length ==0){
-        HLog(@"视频没获取到")
-        [self handleUploadFailOneFileBy:operation];
-        return;
-    }
-        
-    operation.onceDataLengt = [videoData length];
-    KWeakSelf
-    [self startUpload:paraDict operation:operation data:videoData success:^(id  _Nonnull responseObject) {
-        frpUploadModel *model = [[frpUploadModel alloc] initWithDictionary:responseObject error:nil];
-        if(model && model.position >= operation.fileModel.totalBytes){
-            HLog(@"%@上传完成 001",operation.fileModel.filename)
-            [weakSelf handleUploadDoneOneFileBy:operation];
-        }
-        else{
-            HLog(@"%@上传完成一片 %ld",operation.fileModel.filename,model.position)
-            
-            [weakSelf beginUploadVideoDataFunBy:operation with:model.position withPara:paraDict success:^(id  _Nonnull responseObject) {
-                success(responseObject);
-            } faild:^(NSError * _Nonnull error) {
-                NSError *err = error;
-                if(error.code != -999){
-                    faildStr(err);
-                }
-               
-            }];
-        }
-    } faild:^(NSError * _Nonnull error) {
-        HLog(@"%@上传失败",operation.fileModel.filename)
-        [weakSelf handleUploadFailOneFileBy:operation];
-    }];
-    
-}
-
-#pragma mark 分段读视频文件
--(NSData*)cutVideoFileFunAtIndex:(NSUInteger)dataIndex withMaxLenght:(NSInteger)maxLengt withModel:(uploadFileDataModel*)dataModel withOperation:(customUploadOperation*)operation{
-    
-    //return [operation cutVideoFileFunAtIndex:dataIndex withMaxLenght:maxLengt];
-    
-    HLog(@"视频切片开始 线程:%@",[NSThread currentThread]);
-    
-    NSString *filePath = [cachesFileManager getFilePathWithName:dataModel.filename type:uploadFileTypeVideo]; // 文件路径
-    
-    NSFileManager *manager0 = [NSFileManager defaultManager];
-    if(![manager0 fileExistsAtPath:filePath]) {
-     
-        return [NSData new];
-    }
-    
-    NSFileHandle *fileHandle = [NSFileHandle fileHandleForReadingAtPath:filePath]; // 创建文件句柄
-      
-    // 设置分段读取的大小,这里以每次读取1KB为例
-    const NSUInteger chunkSize = maxLengt;//cutVideoPieceSzie;//5 * 1024 *1024;
-    NSMutableData *data = [NSMutableData data];
-    
-    if (fileHandle) {
-       
-        long long endOfFile = [fileHandle seekToEndOfFile];
-        
-        if(dataModel.totalBytes == 0
-           || dataModel.totalBytes < endOfFile){//异常处理
-            dataModel.totalBytes = endOfFile;
-        }
-        
-        //异常处理
-        if(endOfFile == dataIndex){
-            dataModel.totalBytes = endOfFile;
-            dataModel.didUploadBytes = endOfFile;
-            dataModel.curUploadStateType = uploadStateDone;
-            [fileHandle closeFile];
-            return  data;
-        }
-        
-        if (endOfFile >=  chunkSize) {
-            
-            // 读取文件的分段数据到某个位置
-            [fileHandle seekToFileOffset:dataIndex];
-            
-            // 读取文件的分段数据
-            NSData* chunk = [fileHandle readDataOfLength:chunkSize];
-            if (chunk) {
-                [data appendData:chunk];
-            }
-        }
-        else{
-            // 读取文件的分段数据到某个位置
-            [fileHandle seekToFileOffset:dataIndex];
-            
-            [data appendData:[fileHandle readDataToEndOfFile]];
-        }
-        
-        // 在这里可以对文件内容进行处理
-        // ...
-        
-        // 关闭文件句柄
-        [fileHandle closeFile];
-    }
-    
-    HLog(@"视频切片完成 dataIndex:%ld --长度:%ld",dataIndex,[data length])
-    return data;
-}
-
-#pragma mark 处理上传完成
-- (void)handleUploadDoneOneFileBy:(customUploadOperation*)operation
-{
-    HLog(@"handleUploadDoneOneFileBy")
-    [[NSNotificationCenter defaultCenter] postNotificationName:nasUploadTaskExeEnd object:operation.fileModel];
-    [self beginUploadAfterDeleteOperationBy:operation];
-}
-
-#pragma mark 处理删除失败
-- (void)handleUploadFailOneFileBy:(customUploadOperation*)operation
-{
-    operation.fileModel.curUploadStateType = uploadStateFail;
-    [[NSNotificationCenter defaultCenter] postNotificationName:nasUploadTaskExeError object:operation.fileModel];
-    [self beginUploadAfterDeleteOperationBy:operation];
-}
-
-#pragma mark 根据 asset 获取到图片数据
-- (void)afterGetImageDataFunWithOperation:(customUploadOperation*)operation
-{
-    [cachesFileManager getFileNameWithContent:operation.fileModel.imageData fileName:operation.fileModel.filename type:uploadFileTypeImage];
-    
-    [self prepareToUploadFileWithOperation:operation];
-}
-
-#pragma mark 根据 asset 获取到视频数据
-- (void)afterGetVideoDataFunWithOperation:(customUploadOperation*)operation
-{
-    
-    [self prepareToUploadFileWithOperation:operation];
-}
-
-#pragma mark 开始上传
-- (void)startUpload:(NSMutableDictionary *)params operation:(customUploadOperation*)operation data:(NSData *)data success:(netWork_Success)success faild:(netWork_Faild)faildStr {
-    
-    NSString *urlString = ksharedAppDelegate.NASFileByBoxService;
-    urlString = [[NSString alloc] initWithFormat:@"%@uploadFile",urlString];
-    NSURL *URL = [NSURL URLWithString:urlString];
-    NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:URL];
-    [request setHTTPMethod:@"POST"];
-    
-    //请求体
-    NSMutableData *bodyData = [self getBodyDataWithRequest:request withModel:operation.fileModel withData:data withPara:params];
-    
-    //设置请求体
-    [request setHTTPMethod:@"POST"];
-    [request setHTTPBody:bodyData];
-    
-    //设置请求体长度
-    NSInteger length = [bodyData length];
-    [request setValue:[NSString stringWithFormat:@"%ld",length] forHTTPHeaderField:@"Content-Length"];
-    //设置 POST请求文件上传
-    [request setValue:[NSString stringWithFormat:@"multipart/form-data; boundary=%@",Kboundary2]  forHTTPHeaderField:@"Content-Type"];
-
-    KWeakSelf
-    //回话对象
-    NSURLSession *session = [NSURLSession sessionWithConfiguration:[NSURLSessionConfiguration defaultSessionConfiguration] delegate:self delegateQueue:nil];
-    operation.session = session;
-    
-    //请求task
-    /*
-     第一个参数:请求对象
-     第二个参数:传递是要上传的数据(请求体)
-     第三个参数:
-     */
-    NSURLSessionUploadTask *uploadTask = [session uploadTaskWithRequest:request fromData:nil completionHandler:^(NSData * _Nullable data, NSURLResponse * _Nullable response, NSError * _Nullable error) {
-        //解析
-        [weakSelf handleCustomUploadResultBy:data withResponse:response withError:error success:success faild:faildStr];
-    }];
-    
-//    NSString *filePath = [cachesFileManager getFilePathWithName:dataModel.filename type:uploadFileTypeVideo]; // 文件路径
-//    NSURL *filePathUrl = [NSURL URLWithString:filePath];
-//
-//    NSURLSessionUploadTask *uploadTask = [session uploadTaskWithRequest:request fromFile:filePathUrl completionHandler:^(NSData * _Nullable data, NSURLResponse * _Nullable response, NSError * _Nullable error) {
-//        HLog(@"data string:%@",[[NSString alloc]initWithData:data encoding:NSUTF8StringEncoding]);
-    //[weakSelf handleCustomUploadResultBy:data withResponse:response withError:error];
-//    }];
-    
-//    NSURLSessionDataTask *uploadTask = [session dataTaskWithRequest:request completionHandler:^(NSData * _Nullable data, NSURLResponse * _Nullable response, NSError * _Nullable error) {
-//
-//        HLog(@"data string:%@",[[NSString alloc]initWithData:data encoding:NSUTF8StringEncoding]);
-    //[weakSelf handleCustomUploadResultBy:data withResponse:response withError:error];
-//
-////           NSJSONSerialization *object = [NSJSONSerialization JSONObjectWithData:data options:NSJSONReadingMutableLeaves error:nil];
-////           NSDictionary *dict = (NSDictionary *)object;
-////           NSLog(@"=====%@",[dict objectForKey:@"success"]);
-//       }];
-
-    
-    //执行Task
-    [uploadTask resume];
-    operation.dataTask = uploadTask;
-}
-
-#pragma mark 用系统方法写的上传处理
-- (void)handleCustomUploadResultBy:(NSData*)data withResponse:(NSURLResponse*)response withError:(NSError*)error success:(netWork_Success)success faild:(netWork_Faild)faildStr{
-    if(error){
-        HLog(@"上传错误:%@",error)
-        
-        // -1005 网络中断 1009 网络似乎中断
-        if(error.code == -1005
-           ||error.code == -1009){//网络中断
-            [[nasUploadFileManager shareInstance] saveUploadingTaskByNetWorkErrorFun];
-            return;
-        }
-        
-        if(error.code != -999){
-            faildStr(error);
-        }
-        return;
-    }
-    
-    NSJSONSerialization *object = [NSJSONSerialization JSONObjectWithData:data options:NSJSONReadingMutableLeaves error:nil];
-    NSDictionary *dict = (NSDictionary *)object;
-    
-    frpUploadModel *model = [[frpUploadModel alloc] initWithDictionary:dict error:nil];
-    if(model && [model.msg isEqualToString:@"success"]){
-        success(dict);
-    }
-    else{
-        NSError *err = [NSError new];
-        faildStr(err);
-    }
-}
-
-- (NSMutableData *)getBodyDataWithRequest:(NSMutableURLRequest *)request withModel:(uploadFileDataModel*)dataModel withData:(NSData*)data  withPara:(NSMutableDictionary*)params{
-    
-    //1 边界符号要配置请求头里面去
-    /*
-     multipart/form-data 是表单格式
-     charset=utf-8 是utf-8编码
-     bounary 是表单开头
-     */
-    [request setValue:[NSString stringWithFormat:@"multipart/form-data; charset=utf-8; boundary=%@", Kboundary2] forHTTPHeaderField:@"Content-Type"];
-    
-    /// body
-    NSMutableData *boydData = [NSMutableData data];
-    // 2.1 边界符号(开始边界)
-    
-    //2.1.1 其它参数
-    NSMutableString *paraString = [NSMutableString new];
-    //[paraString appendFormat:@"--%@\r\n",Kboundary];//\n:换行 \n:切换到行首
-    for (NSString *key in params) {
-        NSString *value = params[key];
-        [paraString appendFormat:@"--%@\r\n",Kboundary2];//\n:换行 \n:切换到行首
-        [paraString appendFormat:@"Content-Disposition: form-data; name=\"%@\"",key];
-        [paraString appendFormat:@"\r\n"];
-        [paraString appendFormat:@"\r\n"];
-        [paraString appendFormat:@"%@\r\n",value];
-    }
-    
-    //[boydData appendData:[paraString dataUsingEncoding:NSUTF8StringEncoding]];
-    
-    
-    // body每一个段内容以换行符作为结束标示
-    NSString *fileBeginBoundary = [NSString stringWithFormat:@"--%@\r\n", Kboundary2];
-    //[boydData appendData:[fileBeginBoundary dataUsingEncoding:NSUTF8StringEncoding]];
-    
-    [paraString appendString:fileBeginBoundary];
-    
-    // 2.2 属性配置 名字;key;类型
-    
-    NSString *serverFileKey = @"image";  //key
-    //NSString *serverFileKey = @"file";
-    NSString *serverContentTypes = @"image/png";  //类型
-    
-    if (dataModel.curUploadFileType == uploadFileTypeVideo) {
-        serverFileKey = @"video";
-        serverContentTypes = @"video/mp4";
-    }
-    
-    
-    NSString *serverFileName = dataModel.filename;  //name
-
-    
-    // filename已命名文件;  name相当于一个key, 这个名字和服务器保持一致
-    /*
-     理解key,表单发送给服务端,服务端拿到数据之后,可以将任务解析成一个字典了imageDict;图片数据会通过这个字典里面的name来获取图片(伪代码 image =  imageDict[serverFileKey])
-     */
-    //2.3 拼接数据(创建一个字符串来拼装)
-    NSMutableString *string = [NSMutableString new];
-    [string appendFormat:@"Content-Disposition:form-data; name=\"%@\"; filename=\"%@\" ", @"file", serverFileName];
-    //[string appendFormat:@"%@", KNewLine];
-    [string appendFormat:@"\r\n"];
-    [string appendFormat:@"Content-Type:%@", serverContentTypes];
-//    [string appendFormat:@"%@", KNewLine];
-//    [string appendFormat:@"%@", KNewLine];
-    [string appendFormat:@"\r\n"];
-    [string appendFormat:@"\r\n"];
-   // [boydData appendData:[string dataUsingEncoding:NSUTF8StringEncoding]];
-    
-    [paraString appendString:string];
-    [boydData appendData:[paraString dataUsingEncoding:NSUTF8StringEncoding]];
-    
-    // 2.3 拼接数据(拼接文件数据)
-    [boydData appendData:data];
-    
-    // 2.4 边界符号 (结束边界)
-    NSString *fileEndBoundary = [NSString stringWithFormat:@"\r\n--%@--", Kboundary2];
-    [boydData appendData:[fileEndBoundary dataUsingEncoding:NSUTF8StringEncoding]];
-    
-    return boydData;
-}
-
-#pragma mark 上传的文件已存在
-- (void)handleTaskDidUploadWith:(customUploadOperation*)operation withState:(NSInteger)state
-{
-    if(state == 1){
-        [[iToast makeText:NSLocalizedString(@"File_upload_file_already_exists",nil)] show];
-    }
-    
-    HLog(@"上传的文件已存在 删除任务:_uploadingOperationArr:%@",_uploadingOperationArr);
-    [self.uploadingOperationArr removeObject:operation];
-    
-    NSMutableArray *delArr = [NSMutableArray new];
-    [delArr addObject:operation.fileModel];
-    
-    [[nasUploadFileManager shareInstance] deleteUploadFileRecordBy:delArr withDelCache:NO complete:^(BOOL isSuccess) {
-        if (isSuccess) {
-            
-        }
-    }];
-    
-    [self beginUploadAfterDeleteOperationBy:nil];
-}
-    
-
-#pragma mark - <NSURLSessionDataDelegate>
-
-// ssl 服务 证书信任
-- (void)URLSession:(NSURLSession *)session
-didReceiveChallenge:(NSURLAuthenticationChallenge *)challenge
- completionHandler:(void (^)(NSURLSessionAuthChallengeDisposition disposition, NSURLCredential * _Nullable credential))completionHandler{
-    if(![challenge.protectionSpace.authenticationMethod isEqualToString:@"NSURLAuthenticationMethodServerTrust"]) {
-        return;
-    }
-    
-    // 信任该插件
-    NSURLCredential *credential = [[NSURLCredential alloc] initWithTrust:challenge.protectionSpace.serverTrust];
-    // 第一个参数 告诉系统如何处置
-    completionHandler(NSURLSessionAuthChallengeUseCredential,credential);
-}
-
-//当请求协议是https的时候回调用该方法
-//Challenge 挑战 质询(受保护空间)
-//NSURLAuthenticationMethodServerTrust 服务器信任证书
-- (void)URLSession:(NSURLSession *)session
-              task:(NSURLSessionTask *)task
-didReceiveChallenge:(NSURLAuthenticationChallenge *)challenge
- completionHandler:(void (^)(NSURLSessionAuthChallengeDisposition disposition, NSURLCredential * __nullable credential))completionHandler {
-    
-    if(![challenge.protectionSpace.authenticationMethod isEqualToString:@"NSURLAuthenticationMethodServerTrust"]) {
-        return;
-    }
-    
-    // 信任该插件
-    NSURLCredential *credential = [[NSURLCredential alloc] initWithTrust:challenge.protectionSpace.serverTrust];
-    // 第一个参数 告诉系统如何处置
-    completionHandler(NSURLSessionAuthChallengeUseCredential,credential);
-    
-}
-
-
-// 接受到响应调用
-- (void)URLSession:(NSURLSession *)session
-          dataTask:(NSURLSessionDataTask *)dataTask
-didReceiveResponse:(NSURLResponse *)response
- completionHandler:(void (^)(NSURLSessionResponseDisposition disposition))completionHandler {
-    
-    completionHandler(NSURLSessionResponseAllow);
-}
-
-// 上传进度
-- (void)URLSession:(NSURLSession *)session task:(NSURLSessionTask *)task didSendBodyData:(int64_t)bytesSent totalBytesSent:(int64_t)totalBytesSent totalBytesExpectedToSend:(int64_t)totalBytesExpectedToSend{
-    
-    //每包发送的大小bytesSent,totalBytesSent已经上传了多少;totalBytesExpectedToSend总共要发送多少
-    // 32768 = 32KB
-    HLog(@"didSendBodyData: %lld--%lld-%lld", bytesSent, totalBytesSent, totalBytesExpectedToSend);
-    
-    @synchronized (self) {
-        for (customUploadOperation*operation in _uploadingOperationArr) {
-            HLog(@"正在遍历数组 _uploadingOperationArr:%@",_uploadingOperationArr);
-            
-            if(operation.dataTask == task){
-                operation.fileModel.didUploadBytes += bytesSent;
-                
-                //调整下大小 因为上传的数据 除了data 长度 还包含了 参数大小
-                if(totalBytesSent == totalBytesExpectedToSend){
-                    operation.fileModel.didUploadBytes -= (totalBytesExpectedToSend - operation.onceDataLengt);
-                }
-                
-                NSTimeInterval curTime = [[NSDate date] timeIntervalSince1970];
-                NSTimeInterval timeDiff = curTime - operation.preNotTimeInterval;
-                
-                //HLog(@"控制刷新时间为1秒:%f",timeDiff);
-                
-                CGFloat RefreshTimer = 0.8;
-                if(operation.fileModel.totalBytes <= 5*1024*1024){//小于5M 事实
-                    RefreshTimer = 0.2;
-                }
-                
-                if (operation.preNotTimeInterval <= 0
-                    || timeDiff > RefreshTimer ) {
-                    
-                    operation.preNotTimeInterval = curTime;
-                    [[NSNotificationCenter defaultCenter] postNotificationName:uploadFileUploadingNotification object:operation.fileModel];
-                }
-                
-                break;
-            }
-        }
-    }
-}
-
-#pragma mark 取消单个任务
-- (void)cancelUploadTaskFunWith:(uploadFileDataModel*)fileModel
-{
-    HLog(@"取消任务-- %@--%@",fileModel.filename,fileModel.taskId)
-    
-    @synchronized (self) {
-        
-        for (customUploadOperation*operation in _uploadingOperationArr) {
-            HLog(@"正在遍历数组 _uploadingOperationArr:%@",_uploadingOperationArr);
-            if([operation.fileModel.localIdentifier isEqualToString:fileModel.localIdentifier]){
-                operation.isCancelType = YES;
-                [operation.dataTask cancel];
-                
-                if(operation.fileHandle){
-                    [operation closeFileHandleFun];
-                }
-                
-                [self beginUploadAfterDeleteOperationBy:operation];
-                return;
-            }
-        }
-        
-        for (uploadFileDataModel*waitModel in _uploadWaitingUrlArr) {
-            if(//[waitModel.filename isEqualToString:fileModel.filename]
-               [waitModel.localIdentifier isEqualToString:fileModel.localIdentifier]){
-                [_uploadWaitingUrlArr removeObject:waitModel];
-                [self beginUploadAfterDeleteOperationBy:nil];
-                return;
-            }
-        }
-        
-    }
-}
-
-#pragma mark 取消所有任务
-- (void)cancelUploadAllTaskFun
-{
-    HLog(@"取消所有任务")
-    @synchronized (self) {
-        [_uploadWaitingUrlArr removeAllObjects];
-        
-        for (customUploadOperation*operation in _uploadingOperationArr) {
-            HLog(@"正在遍历数组 _uploadingOperationArr:%@",_uploadingOperationArr);
-            operation.isCancelType = YES;
-            [operation.dataTask cancel];
-            if(operation.fileHandle){
-                [operation closeFileHandleFun];
-            }
-        }
-        
-        [_uploadingOperationArr removeAllObjects];
-    }
-}
-
-
-#pragma mark 判断是否在上传中
-- (BOOL)checkUploadTaskDoingFun
-{
-    if(_uploadWaitingUrlArr.count >0 || _uploadingOperationArr.count>0){
-        return YES;
-    }
-    
-    return NO;
-}
-
-
-- (BOOL)isUploadIngType
-{
-    if(self.uploadWaitingUrlArr.count >0){
-        return YES;
-    }
-    
-    if(self.uploadingOperationArr.count >0){
-        return YES;
-    }
-    
-    return NO;
-}
-
-#pragma mark - lazy load
-- (NSMutableArray *)uploadWaitingUrlArr {
-    
-    if (!_uploadWaitingUrlArr) {
-        _uploadWaitingUrlArr = [NSMutableArray array];
-    }
-    return _uploadWaitingUrlArr;
-}
-
-- (NSMutableArray *)uploadingOperationArr {
-    
-    if (!_uploadingOperationArr) {
-        _uploadingOperationArr = [NSMutableArray array];
-    }
-    return _uploadingOperationArr;
-}
-@end

+ 3 - 0
创维盒子/code/NAS/nasUploadManager/nasUploadFileManager.h

@@ -34,6 +34,9 @@ NS_ASSUME_NONNULL_BEGIN
 //把TZAssetModel 转成 我们需要上传的model
 - (void)handlTZAssetModelToUploadFileDataFunBy:(NSMutableArray*)indexPathsForSelectedItems complete:(custom_complete_Arr)complete;
 
+//把url 转成 我们需要上传的model
+- (void)handlUrlToUploadFileDataFunBy:(NSArray*)UrlArr complete:(custom_complete_Arr)complete;
+
 //删除本地数据库记录
 - (void)deleteUploadFileRecordBy:(NSMutableArray *)delArr withDelCache:(BOOL)isDelCache complete:(custom_complete_B)complete;
 

+ 104 - 15
创维盒子/code/NAS/nasUploadManager/nasUploadFileManager.m

@@ -102,17 +102,17 @@
         return;
     }
     
-    if(ksharedAppDelegate.DisabledFileTransferType){
-        if(ksharedAppDelegate.isImageNewFor130){
-            [[iToast makeText:NSLocalizedString(@"File_Transfer_Disable_tip",nil)] show];
-        }
-        else{
-            [[iToast makeText:NSLocalizedString(@"File_Transfer_Disable_tip2",nil)] show];
-        }
-        
-        complete(_databaseArr);
-        return;
-    }
+//    if(ksharedAppDelegate.DisabledFileTransferType){
+//        if(ksharedAppDelegate.isImageNewFor130){
+//            [[iToast makeText:NSLocalizedString(@"File_Transfer_Disable_tip",nil)] show];
+//        }
+//        else{
+//            [[iToast makeText:NSLocalizedString(@"File_Transfer_Disable_tip2",nil)] show];
+//        }
+//
+//        complete(_databaseArr);
+//        return;
+//    }
     
     _isNewAddTaskType = YES;
     
@@ -276,6 +276,9 @@
     if(uploadFileDataMod.curUploadFileType == uploadFileTypeVideo){
         [cachesFileManager removeItemAtPath:uploadFileDataMod.filename type:uploadFileTypeVideo error:nil];
     }
+    else if(uploadFileDataMod.curUploadFileType == uploadFileTypeFileAPP){
+        [cachesFileManager removeItemAtPath:uploadFileDataMod.filename type:uploadFileTypeFileAPP error:nil];
+    }
     
     uploadFileDataMod = nil;
 }
@@ -322,7 +325,7 @@
 //        NSMutableArray *ingArr = _databaseArr[0];
 //       NSMutableArray* doneArr = _databaseArr[1];
 //       NSMutableArray* failArr = _databaseArr[2];
-//        
+//
 //        NSString *logstr = [[NSString alloc] initWithFormat:@"nasUploadFileChangeingOneFileFunBy ing:%ld,done:%ld,fail:%ld---total:%ld",ingArr.count,doneArr.count,failArr.count,ingArr.count + doneArr.count +failArr.count];
 //        [cachesFileManager writeLogsWithMsg:logstr];
 //    }
@@ -711,9 +714,9 @@
         
 //        NSMutableArray* doneArr = _databaseArr[1];
 //        NSMutableArray* failArr = _databaseArr[2];
-//        
+//
 //        NSString *logstr = [[NSString alloc] initWithFormat:@"ing:%ld,done:%ld,fail:%ld",self.uploadingArr.count,doneArr.count,failArr.count];
-//        
+//
 //        [cachesFileManager writeLogsWithMsg:logstr];
         
         //1.修改状态从失败改为上传中
@@ -729,7 +732,7 @@
         
         //2、保存到数控库
 //        [uploadFileDataModel bg_saveOrUpdateArrayAsync:_netWorkFailSaveArr complete:^(BOOL isSuccess) {
-//            
+//
 //        }];
         
         //3.判断是否可以上传
@@ -746,4 +749,90 @@
         [[nasMixUploadManager shareManager] addUploadWithModels:self.uploadingArr];
     }
 }
+
+
+
+#pragma mark 文件APP里的文件上传
+- (void)handlUrlToUploadFileDataFunBy:(NSArray*)UrlArr complete:(custom_complete_Arr)complete
+{
+    if(!UrlArr && UrlArr.count == 0){
+        complete(_databaseArr);
+        return;
+    }
+    
+    _isNewAddTaskType = YES;
+    
+    NSMutableArray *newUploadTaskArr = [NSMutableArray new];
+    
+    for (NSURL * fileURL in UrlArr) {
+        uploadFileDataModel * curModel = [uploadFileDataModel new];
+        
+        // 获取文件名称
+        NSString *fileName = [fileURL lastPathComponent];
+        curModel.filename = fileName;
+        curModel.curUploadFileType = uploadFileTypeFileAPP;
+        BOOL isRepeatingTasksType = NO;
+        
+        //查询上传任务是否存在
+        if(_databaseArr && _databaseArr.count == 3 ){
+            NSMutableArray *uploadingArr = [[NSMutableArray alloc] initWithArray:_databaseArr[0]];
+            for (uploadFileDataModel *preModel in uploadingArr) {
+                if([preModel.filename isEqualToString:curModel.filename]
+                   && preModel.curUploadFileType ==  uploadFileTypeFileAPP){
+                    isRepeatingTasksType = YES;
+                    break;
+                }
+            }
+        }
+        
+        if(isRepeatingTasksType){
+            continue;
+        }
+        
+        NSString * uploadDefaultPath = [HWDataManager getStringWithKey:stringKeyAddSn(Const_photo_upload_default_path)];
+        if(!uploadDefaultPath || uploadDefaultPath.length == 0){
+            [HWDataManager setStringWithKey:stringKeyAddSn(Const_photo_upload_default_path) value:Const_default_upload_path];
+            uploadDefaultPath = Const_default_upload_path;
+        }
+        
+        //判断最后一个是否是/
+        NSString *lastStr= [uploadDefaultPath substringFromIndex:uploadDefaultPath.length-1];
+        if(![lastStr isEqualToString:@"/"]){
+            uploadDefaultPath = [[NSString alloc] initWithFormat:@"%@/",uploadDefaultPath];
+        }
+        
+        //NSString*savePath = [[NSString alloc] initWithFormat:@"%@%@",uploadDefaultPath,filePath];
+        curModel.savePath = uploadDefaultPath;
+        
+        curModel.curUploadStateType = uploadStateUploading;
+        
+        NSString *documentsDirectory = kSHPath_FileAPP;
+        // 构建目标文件路径
+        NSString *destinationPath = [documentsDirectory stringByAppendingPathComponent:fileName];
+        
+        curModel.totalBytes = [iTools getFileSize:destinationPath];
+        
+        //保存到数据库
+        curModel.bg_tableName = nasUpLoadFile_tableName;
+        [newUploadTaskArr addObject:curModel];
+        
+    }
+    
+    KWeakSelf
+    if(newUploadTaskArr.count == 0){
+        [self getDataInDatabaseFun:YES complete:^(NSMutableArray * _Nonnull Arr) {
+            complete(Arr);
+            [weakSelf handleUploadFileModelBg_idFun:Arr];
+        }];
+    }
+    else{
+        [uploadFileDataModel bg_saveOrUpdateArrayAsync:newUploadTaskArr complete:^(BOOL isSuccess) {
+            [weakSelf getDataInDatabaseFun:YES complete:^(NSMutableArray * _Nonnull Arr) {
+                complete(Arr);
+                [weakSelf handleUploadFileModelBg_idFun:Arr];
+            }];
+        }];
+    }
+}
+
 @end

+ 0 - 52
创维盒子/code/NAS/nasUploadManager/nasUploadFileManager~.h

@@ -1,52 +0,0 @@
-//
-//  nasUploadFileManager.h
-//  双子星云手机
-//
-//  Created by xd h on 2024/8/7.
-//
-
-#import <Foundation/Foundation.h>
-#import "uploadFileManager.h"
-#import "frpUploadModel.h"
-#import "frpFileExistModel.h"
-#import "nasMixUploadManager.h"
-
-NS_ASSUME_NONNULL_BEGIN
-
-#define nasUpLoadFile_tableName [[NSString alloc] initWithFormat:@"upLoadFile_tableName_%@",ksharedAppDelegate.DeviceThirdIdMod.data.sn]
-
-@interface nasUploadFileManager : NSObject
-+(instancetype)shareInstance;
-//数据库数据
-@property (atomic, strong) NSMutableArray * _Nullable databaseArr;
-@property (atomic, strong) NSMutableArray * _Nullable uploadingArr;
-
-@property (nonatomic, assign) BOOL  isSuspendType;
-//@property (nonatomic, assign) BOOL  isUploadIngType;//弃用
-@property (nonatomic, assign) BOOL  isNewAddTaskType;
-//@property (nonatomic, assign) NSInteger  curUploadModelNumbers;
-@property (nonatomic, assign) NSInteger  reUploadIngSelectIndex;
-@property (nonatomic, assign) BOOL  needToReUploadTaskType;//
-
-#pragma mark 读取数据库数据
-- (void)getDataInDatabaseFun:(BOOL)isReGet complete:(custom_complete_Arr)complete;
-
-//把TZAssetModel 转成 我们需要上传的model
-- (void)handlTZAssetModelToUploadFileDataFunBy:(NSMutableArray*)indexPathsForSelectedItems complete:(custom_complete_Arr)complete;
-
-//删除本地数据库记录
-- (void)deleteUploadFileRecordBy:(NSMutableArray *)delArr withDelCache:(BOOL)isDelCache complete:(custom_complete_B)complete;
-
-- (void)checkHadUploadTaskWithComplete:(custom_complete_B)complete;
-
-//文件重新上传
-- (void)reUploadFileFunBy:(NSMutableArray*)Arr withAll:(BOOL)isAllType;
-//暂停上传 当 isSuspendAll为NO时候 传指定暂停哪一个
-- (void)suspendUploadFileFun:(BOOL)isSuspendAll withModel:(uploadFileDataModel*)model;
-//网络失败后任务暂时保存
-- (void)saveUploadingTaskByNetWorkErrorFun;
-//重新上传网络失败的任务
-- (void)reUploadFileFunByNetWork;
-@end
-
-NS_ASSUME_NONNULL_END

+ 0 - 749
创维盒子/code/NAS/nasUploadManager/nasUploadFileManager~.m

@@ -1,749 +0,0 @@
-//
-//  nasUploadFileManager.m
-//  双子星云手机
-//
-//  Created by xd h on 2024/8/7.
-//
-
-#import "nasUploadFileManager.h"
-#import "nasUploadManager.h"
-
-@implementation nasUploadFileManager
-+ (instancetype)shareInstance {
-    static nasUploadFileManager *_instance;
-    static dispatch_once_t onceToken;
-    dispatch_once(&onceToken, ^{
-        _instance = [[self alloc] init];
-    });
-    return _instance;
-}
-
-- (id)init
-{
-    self = [super init];
-    if (self) {
-        [self initManager];
-    }
-    return self;
-}
-
-- (void)initManager
-{
-  
-    [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(uploadTaskFinishedNoti:) name:nasUploadTaskExeEnd object:nil];
-    [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(uploadTaskErrorNoti:) name:nasUploadTaskExeError object:nil];
-}
-
-#pragma mark 读取数据库数据
-- (void)getDataInDatabaseFun:(BOOL)isReGet complete:(custom_complete_Arr)complete
-{
-    if(_databaseArr && _databaseArr.count == 3 && !isReGet){
-        complete(_databaseArr);
-        return;
-    }
-    
-    if(!_databaseArr)
-    {
-        _databaseArr = [NSMutableArray new];
-    }
-    
-    //KWeakSelf
-    dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT,0), ^{
-
-        HLog(@"begin bg_findAsync");
-        [uploadFileDataModel bg_findAsync:nasUpLoadFile_tableName limit:0 orderBy:nil desc:YES complete:^(NSArray * _Nullable array) {
-            HLog(@"end bg_findAsync");
-            NSMutableArray *failArr = [NSMutableArray new];
-            NSMutableArray *doneArr = [NSMutableArray new];
-            NSMutableArray *otherArr = [NSMutableArray new];
-            
-                for (uploadFileDataModel * curModel in array) {
-                    
-                    //图片 和视频 还原
-                    if(curModel.curUploadFileType == uploadFileTypeImage){
-
-                    }
-                    else if(curModel.curUploadFileType == uploadFileTypeVideo){
-
-                        if(curModel.curUploadStateType != uploadStateDone){
-                    
-                        }
-                    }
-                    
-                    if(curModel.curUploadStateType == uploadStateFail){
-                        [failArr addObject:curModel];
-                    }
-                    else if(curModel.curUploadStateType == uploadStateDone){
-                        [doneArr addObject:curModel];
-                    }
-                    else{
-                        [otherArr addObject:curModel];
-                    }
-                }
-            
-            NSMutableArray *newArr = [NSMutableArray new];
-            [newArr addObject:otherArr];
-            [newArr addObject:doneArr];
-            [newArr addObject:failArr];
-            self->_databaseArr = newArr;
-            
-            complete(self->_databaseArr);
-        }];
-
-    });
-
-}
-
-//把TZAssetModel 转成 我们需要上传的model
-- (void)handlTZAssetModelToUploadFileDataFunBy:(NSMutableArray*)indexPathsForSelectedItems complete:(custom_complete_Arr)complete
-{
-    if(!indexPathsForSelectedItems && indexPathsForSelectedItems.count == 0){
-        complete(_databaseArr);
-        return;
-    }
-    
-    if(ksharedAppDelegate.DisabledFileTransferType){
-        if(ksharedAppDelegate.isImageNewFor130){
-            [[iToast makeText:NSLocalizedString(@"File_Transfer_Disable_tip",nil)] show];
-        }
-        else{
-            [[iToast makeText:NSLocalizedString(@"File_Transfer_Disable_tip2",nil)] show];
-        }
-        
-        complete(_databaseArr);
-        return;
-    }
-    
-    _isNewAddTaskType = YES;
-    
-    //self.curUploadModelNumbers = indexPathsForSelectedItems.count;
-    
-    NSMutableArray *newUploadTaskArr = [NSMutableArray new];
-    
- 
-    
-    for (TZAssetModel * model in indexPathsForSelectedItems) {
-        uploadFileDataModel * curModel = [uploadFileDataModel new];
-        curModel.asset = model.asset;
-        curModel.localIdentifier = model.asset.localIdentifier;
-        
-        BOOL isRepeatingTasksType = NO;
-        
-        //查询上传任务是否存在
-        if(_databaseArr && _databaseArr.count == 3 ){
-            NSMutableArray *uploadingArr = [[NSMutableArray alloc] initWithArray:_databaseArr[0]];
-            for (uploadFileDataModel *preModel in uploadingArr) {
-                if([preModel.localIdentifier isEqualToString:curModel.localIdentifier]){
-                    isRepeatingTasksType = YES;
-                    break;
-                }
-            }
-        }
-        
-        
-        if(isRepeatingTasksType){
-            continue;
-        }
-        
-        NSString * uploadDefaultPath = [HWDataManager getStringWithKey:stringKeyAddSn(Const_photo_upload_default_path)];
-        if(!uploadDefaultPath || uploadDefaultPath.length == 0){
-            [HWDataManager setStringWithKey:stringKeyAddSn(Const_photo_upload_default_path) value:Const_default_upload_path];
-            uploadDefaultPath = Const_default_upload_path;
-        }
-        
-        //判断最后一个是否是/
-        NSString *lastStr= [uploadDefaultPath substringFromIndex:uploadDefaultPath.length-1];
-        if(![lastStr isEqualToString:@"/"]){
-            uploadDefaultPath = [[NSString alloc] initWithFormat:@"%@/",uploadDefaultPath];
-        }
-        
-        //NSString*savePath = [[NSString alloc] initWithFormat:@"%@%@",uploadDefaultPath,filePath];
-        curModel.savePath = uploadDefaultPath;
-        
-//        curModel.imageData = model.imageData;
-//        curModel.videoData = model.videoData;
-        curModel.filename = [model.asset valueForKey:@"filename"];
-        //curModel.curUploadStateType = uploadStateWait;
-        curModel.curUploadStateType = uploadStateUploading;
-        
-        if(model.type == TZAssetModelMediaTypeVideo){
-            curModel.curUploadFileType = uploadFileTypeVideo;
-            [cachesFileManager getFileNameWithContent:curModel.videoData fileName:curModel.filename type:uploadFileTypeVideo];
-            
-            
-            //curModel.totalBytes = [model.videoData length];
-            curModel.totalBytes = model.totalBytes;
-            curModel.videoData = [NSData new];//视频文件存储到文件后内存清空
-            
-            NSString *imgName1 = [curModel.filename stringByReplacingOccurrencesOfString:@"." withString:@"_"];
-            curModel.videoFirstImageName = [[NSString alloc] initWithFormat:@"%@.png",imgName1];
-           
-            //第一帧图片
-            [[PHImageManager defaultManager] requestImageDataForAsset:curModel.asset options:nil resultHandler:^(NSData * _Nullable imageData, NSString * _Nullable dataUTI, UIImageOrientation orientation, NSDictionary * _Nullable info) {
-                    // 直接得到最终的 NSData 数据
-                    if (imageData) {
-                        curModel.imageData = imageData;
-                        [cachesFileManager getFileNameWithContent:curModel.imageData fileName:curModel.videoFirstImageName type:uploadFileTypeImage];
-                    }
-            }];
-
-        }
-        else{
-            curModel.curUploadFileType = uploadFileTypeImage;
-            curModel.totalBytes = model.totalBytes;
-            
-            if(curModel.imageData)
-            {
-                [cachesFileManager getFileNameWithContent:curModel.imageData fileName:curModel.filename type:uploadFileTypeImage];
-                curModel.imageData = nil;
-            }
-            else{
-                
-            }
-           
-        }
-        
-        //保存到数据库
-        curModel.bg_tableName = nasUpLoadFile_tableName;
-        [newUploadTaskArr addObject:curModel];
-        
-    }
-    
-    KWeakSelf
-    if(newUploadTaskArr.count == 0){
-        [self getDataInDatabaseFun:YES complete:^(NSMutableArray * _Nonnull Arr) {
-            complete(Arr);
-            [weakSelf handleUploadFileModelBg_idFun:Arr];
-        }];
-    }
-    else{
-        [uploadFileDataModel bg_saveOrUpdateArrayAsync:newUploadTaskArr complete:^(BOOL isSuccess) {
-            [weakSelf getDataInDatabaseFun:YES complete:^(NSMutableArray * _Nonnull Arr) {
-                complete(Arr);
-                [weakSelf handleUploadFileModelBg_idFun:Arr];
-            }];
-        }];
-    }
-}
-
-#pragma mark 处理当前的model 加上bg_id
-- (void)handleUploadFileModelBg_idFun:(NSMutableArray*)totalArr
-{
-    if(!totalArr || totalArr.count != 3){
-        return;
-    }
-    
-    NSMutableArray* uploadTaskArr = [NSMutableArray arrayWithArray:totalArr[0]];
-    
-    //多任务同时进行模式
-    if(uploadTaskArr.count >0){
-        [[nasMixUploadManager shareManager] addUploadWithModels:uploadTaskArr];
-    }
-}
-
-#pragma mark 上传完成
-- (void)uploadTaskFinishedNoti:(NSNotification *)notification
-{
-    uploadFileDataModel *model = notification.object;
-    
-    if(!model)return;
-    
-    model.curUploadStateType = uploadStateDone;
-    [self nasUploadFileChangeingOneFileFunBy:model];
-    [self deleteCacheDataBy:model];
-}
-
-#pragma mark 上传失败
-- (void)uploadTaskErrorNoti:(NSNotification *)notification
-{
-    uploadFileDataModel *model = notification.object;
-    
-    if(!model)return;
-    
-    model.curUploadStateType = uploadStateFail;
-    [self nasUploadFileChangeingOneFileFunBy:model];
-    [self deleteCacheDataBy:model];
-}
-    
-
-#pragma mark 上传完成 清理缓存
-- (void)deleteCacheDataBy:(uploadFileDataModel*)uploadFileDataMod
-{
-    HLog(@"上传--清理缓存")
-    uploadFileDataMod.imageData = nil;
-    uploadFileDataMod.videoData = nil;
-    
-    if(uploadFileDataMod.curUploadFileType == uploadFileTypeVideo){
-        [cachesFileManager removeItemAtPath:uploadFileDataMod.filename type:uploadFileTypeVideo error:nil];
-    }
-    
-    uploadFileDataMod = nil;
-}
-
-#pragma mark 更新数据状态
-- (void)nasUploadFileChangeingOneFileFunBy:(uploadFileDataModel*)dataModel
-{
-    //test code
-    //return;
-    HLog(@"更新数据状态")
-    
-    if(dataModel.curUploadStateType == uploadStateDone){
-        [self handleDatabaseArrDeleteObjectInUploading:dataModel];
-        [self handleDatabaseArrAddObjectInDone:dataModel];
-        
-    }
-    else if(dataModel.curUploadStateType == uploadStateFail){
-        
-        if (!_databaseArr || _databaseArr.count != 3) {
-            return;
-        }
-        
-        //删除操作导致的失败
-        NSMutableArray *ingArr = _databaseArr[0];
-        NSInteger count = ingArr.count;
-        if(count == 0){
-            return;
-        }
-        
-        [self handleDatabaseArrDeleteObjectInUploading:dataModel];
-        [self handleDatabaseArrAddObjectInFail:dataModel];
-    }
-    else{
-        //[cachesFileManager writeLogsWithMsg:@"nasUploadFileChangeingOneFileFunBy else"];
-    }
-
-    dataModel.bg_tableName = nasUpLoadFile_tableName;
-    [dataModel bg_saveOrUpdateAsync:^(BOOL isSuccess) {
-        HLog(@"%@ 写入 %@", dataModel.filename, isSuccess ? @"成功":@"失败");
-    }];
-        
-//    if(_databaseArr.count == 3)
-//    {
-//        NSMutableArray *ingArr = _databaseArr[0];
-//       NSMutableArray* doneArr = _databaseArr[1];
-//       NSMutableArray* failArr = _databaseArr[2];
-//        
-//        NSString *logstr = [[NSString alloc] initWithFormat:@"nasUploadFileChangeingOneFileFunBy ing:%ld,done:%ld,fail:%ld---total:%ld",ingArr.count,doneArr.count,failArr.count,ingArr.count + doneArr.count +failArr.count];
-//        [cachesFileManager writeLogsWithMsg:logstr];
-//    }
-    
-    
-    if(!_isSuspendType || dataModel.curUploadStateType != uploadStateSuspend){
-        HLog(@"nasUploadFileChangeingOneFileFunBy uploadFileRefreshNotification")
-        [[NSNotificationCenter defaultCenter] postNotificationName:uploadFileRefreshNotification object:dataModel];
-    }
-    
-}
-
-#pragma mark 删除上传中的任务
-- (void)handleDatabaseArrDeleteObjectInUploading:(uploadFileDataModel*)model
-{
-    HLog(@"删除上传中的任务")
-    @synchronized (self) {
-        
-        if(_databaseArr && _databaseArr.count == 3 ){
-            
-            NSMutableArray *ingArr = _databaseArr[0];
-            NSInteger count = ingArr.count;
-            [ingArr removeObject:model];
-            
-            NSInteger atferDelCount = ingArr.count;
-            
-            if(count == atferDelCount){
-//                NSString* logStr = [[NSString alloc] initWithFormat:@"DeleteObjectInUploading error begin %ld--model:%@--%@",ingArr.count,model,model.filename];
-//                HLog(@"%@",logStr)
-//                [cachesFileManager writeLogsWithMsg:logStr];
-                
-                for (uploadFileDataModel*preModel in ingArr) {
-                    if(preModel.bg_id.integerValue == model.bg_id.integerValue){
-                        if (//[preModel.filename isEqualToString:model.filename]&&
-                            [preModel.localIdentifier isEqualToString:model.localIdentifier]) {
-                            [ingArr removeObject:preModel];
-                        }else{
-//                            NSString* logStr22 = [[NSString alloc] initWithFormat:@"filename error %@",preModel.filename];
-//                            [cachesFileManager writeLogsWithMsg:logStr22];
-                        }
-                        break;
-                    }
-                }
-                NSString* logStr2 = [[NSString alloc] initWithFormat:@"DeleteObjectInUploading error end %ld",ingArr.count];
-                HLog(@"%@",logStr2)
-                //[cachesFileManager writeLogsWithMsg:logStr2];
-                
-            }
-        }
-    }
-}
-
-#pragma mark 添加任务到上传完成
-- (void)handleDatabaseArrAddObjectInDone:(uploadFileDataModel*)model
-{
-    HLog(@"添加任务到上传完成")
-    @synchronized (self) {
-        if(_databaseArr && _databaseArr.count == 3 ){
-            NSMutableArray *doneArr = _databaseArr[1];
-            if(model){
-                [doneArr insertObject:model atIndex:0];
-            }
-        }
-    }
-}
-
-#pragma mark 添加任务到上传失败
-- (void)handleDatabaseArrAddObjectInFail:(uploadFileDataModel*)model
-{
-    HLog(@"添加任务到上传失败")
-    @synchronized(self){
-        if(_databaseArr && _databaseArr.count == 3 ){
-            NSMutableArray *failArr = _databaseArr[2];
-            if(model){
-                [failArr insertObject:model atIndex:0];
-            }
-
-        }
-    }
-}
-
-#pragma mark 上传完成所有任务
-- (void)didUploadAllTaskDoneFun
-{
-    //self->_isUploadIngType = NO;
-    [[NSNotificationCenter defaultCenter] postNotificationName:uploadFileAllTaskDoneNotification object:nil];
-}
-
-
-#pragma mark 删除内存数据记录
-- (void)handleDatabaseArrByDelete:(uploadFileDataModel*)delModel
-{
-    if(_databaseArr && _databaseArr.count == 3 ){
-        
-        NSMutableArray *uploadingArr = nil;
-        
-        if(delModel.curUploadStateType == uploadStateUploading
-           ||delModel.curUploadStateType == uploadStateSuspend
-           ||delModel.curUploadStateType == uploadStateWait){
-            uploadingArr = _databaseArr[0];
-        }
-        else if(delModel.curUploadStateType == uploadStateDone)
-        {
-            uploadingArr = _databaseArr[1];
-        }
-        else{
-            uploadingArr = _databaseArr[2];
-        }
-        
-        [uploadingArr removeObject:delModel];
-    }
-}
-
-#pragma mark 删除本地数据库记录
-- (void)deleteUploadFileRecordBy:(NSMutableArray *)delArr withDelCache:(BOOL)isDelCache complete:(custom_complete_B)complete
-{
-    //
-    BOOL isDelUploadingModel = NO;
-    
-    NSMutableArray *curDelArr = [NSMutableArray arrayWithArray:delArr];
-    for (uploadFileDataModel *uploadFileDataMod in curDelArr) {
-        
-        //1.删除数据库
-        NSMutableString* where = [[NSMutableString alloc] initWithString:@"where "];
-        NSString *curStr =  [NSString stringWithFormat:@"%@=%@ ",bg_sqlKey(@"bg_id"),bg_sqlValue(uploadFileDataMod.bg_id)];
-        [where appendString:curStr];
-        //isSuc = [uploadFileDataModel bg_delete:nasUpLoadFile_tableName where:where];
-        [uploadFileDataModel bg_deleteAsync:nasUpLoadFile_tableName where:where complete:^(BOOL isSuccess) {
-            if(isSuccess){
-            }
-        }];
-        
-        // 2.删除内存数据
-        [self handleDatabaseArrByDelete:uploadFileDataMod];
-
-        //3.删除缓存的本地数据
-        if(isDelCache){
-            //判断是否可以删除本地缓存
-            if(_databaseArr && _databaseArr.count == 3 ){
-                NSMutableArray *uploadingArr = _databaseArr[0];
-                NSMutableArray *uploadDoneArr = _databaseArr[1];
-                NSMutableArray *uploadFailArr = _databaseArr[2];
-                
-                
-                BOOL isNeedDel = YES;
-                for (uploadFileDataModel *baseUploadFileDataMod in uploadingArr) {
-                    if([uploadFileDataMod.filename isEqualToString:baseUploadFileDataMod.filename] ){
-                        isNeedDel = NO;
-                        break;
-                    }
-                }
-                
-                if(isNeedDel){
-                    for (uploadFileDataModel *baseUploadFileDataMod in uploadDoneArr) {
-                        if([uploadFileDataMod.filename isEqualToString:baseUploadFileDataMod.filename] ){
-                            isNeedDel = NO;
-                            break;
-                        }
-                    }
-                }
-                
-                if(isNeedDel){
-                    for (uploadFileDataModel *baseUploadFileDataMod in uploadFailArr) {
-                        if([uploadFileDataMod.filename isEqualToString:baseUploadFileDataMod.filename] ){
-                            isNeedDel = NO;
-                            break;
-                        }
-                    }
-                }
-                
-                if(isNeedDel){
-                    if(uploadFileDataMod.curUploadFileType == uploadFileTypeVideo){
-                        [cachesFileManager removeItemAtPath:uploadFileDataMod.videoFirstImageName type:uploadFileTypeImage error:nil];
-                        
-                        [cachesFileManager removeItemAtPath:uploadFileDataMod.filename type:uploadFileTypeVideo error:nil];
-                    }
-                    else{
-                        [cachesFileManager removeItemAtPath:uploadFileDataMod.filename type:uploadFileTypeImage error:nil];
-                    }
-                }
-            }
-        }
-        
-        if(!isDelCache){//上传报云机已经存在文件了 查询本地是否有任务记录
-            [self handleRetryUploadAndDelRecordFun:uploadFileDataMod];
-        }
-        
-        //是否在删除上传中的任务
-        if(uploadFileDataMod.curUploadStateType == uploadStateUploading){
-            [[nasMixUploadManager shareManager] cancelUploadTaskFunWith:uploadFileDataMod];
-        }
-        
-    }
-    
-        
-    uploadFileDataModel *RefreshUploadFileDataMod = nil;
-    if(delArr.count >=  1){
-        RefreshUploadFileDataMod = delArr.firstObject;
-    }
-    [[NSNotificationCenter defaultCenter] postNotificationName:uploadFileRefreshNotification object:RefreshUploadFileDataMod];
-    
-    complete(YES);
-    
-}
-
-#pragma mark 处理重复上传文件的问题
-- (void)handleRetryUploadAndDelRecordFun:(uploadFileDataModel *)uploadFileDataMod
-{
-    @synchronized (self) {
-        
-    
-    if (!_databaseArr || _databaseArr.count != 3) {
-        return;
-    }
-    
-    NSMutableArray * doneArr = _databaseArr[1];
-    NSMutableArray * failArr = _databaseArr[2];
-    
-    BOOL isNeedDelType = YES;
-    
-    for (uploadFileDataModel *doneModel in doneArr) {
-        if([doneModel.localIdentifier isEqualToString:uploadFileDataMod.localIdentifier]){
-            isNeedDelType = NO;
-            break;
-        }
-    }
-    
-    if(isNeedDelType){
-        for (uploadFileDataModel *failModel in failArr) {
-            if([failModel.localIdentifier isEqualToString:uploadFileDataMod.localIdentifier]){
-                isNeedDelType = NO;
-                break;
-            }
-        }
-    }
-    
-    if(isNeedDelType){
-        if(uploadFileDataMod.curUploadFileType == uploadFileTypeVideo){
-            [cachesFileManager removeItemAtPath:uploadFileDataMod.videoFirstImageName type:uploadFileTypeImage error:nil];
-            
-            [cachesFileManager removeItemAtPath:uploadFileDataMod.filename type:uploadFileTypeVideo error:nil];
-        }
-        else{
-            [cachesFileManager removeItemAtPath:uploadFileDataMod.filename type:uploadFileTypeImage error:nil];
-        }
-    }
-    else{//视频文件是要删除的
-        if(uploadFileDataMod.curUploadFileType == uploadFileTypeVideo){
-            [cachesFileManager removeItemAtPath:uploadFileDataMod.filename type:uploadFileTypeVideo error:nil];
-        }
-    }
-    
-    }
-}
-
-- (void)checkHadUploadTaskWithComplete:(custom_complete_B)complete
-{
-    [self getDataInDatabaseFun:NO complete:^(NSMutableArray * _Nonnull Arr) {
-        mainBlock(^{
-            if(!Arr || Arr.count != 3){
-                complete(NO);
-            }
-            else{
-                NSArray *firstArr = Arr[0];
-                if(firstArr.count >0){
-                    complete(YES);
-                }
-                else{
-                    complete(NO);
-                }
-            }
-        });
-        
-    }];
-}
-
-//文件重新上传
-- (void)reUploadFileFunBy:(NSMutableArray*)Arr withAll:(BOOL)isAllType
-{
-    if(!Arr || Arr.count == 0){
-        return;
-    }
-    
-    
-    //1.修改状态从失败改为上传中
-    for (uploadFileDataModel * model in Arr) {
-        model.curUploadStateType = uploadStateUploading;
-        
-        //修改已经读取的内存数据
-        NSMutableArray * failArr = _databaseArr[2];
-        for (uploadFileDataModel * failModel in failArr) {
-            if(model.bg_id.integerValue == failModel.bg_id.integerValue){
-                [failArr removeObject:failModel];
-                break;
-            }
-        }
-        
-    }
-    
-    //2、保存到数控库
-    [uploadFileDataModel bg_saveOrUpdateArrayAsync:Arr complete:^(BOOL isSuccess) {
-        
-    }];
-    
-    //重新开始上传
-    [[nasMixUploadManager shareManager] addUploadWithModels:Arr];
-   
-}
-
-//暂停上传 当 isSuspendAll为NO时候 传指定暂停哪一个
-- (void)suspendUploadFileFun:(BOOL)isSuspendAll withModel:(uploadFileDataModel*)model
-{
-    //[[nasUploadManager shareInstance] cancelUploadTaskFun];
-    
-    if (isSuspendAll) {
-        [[nasMixUploadManager shareManager] cancelUploadAllTaskFun];
-    }
-    else{
-        [[nasMixUploadManager shareManager] cancelUploadTaskFunWith:model];
-    }
-    
-    
-    [self suspendUploadingTaskBy:isSuspendAll withModel:model];
-}
-
-#pragma mark 暂停任务
-- (void)suspendUploadingTaskBy:(BOOL)isDeleteAll withModel:(uploadFileDataModel*)model
-{
-    NSMutableArray *uploadingArr = [NSMutableArray new];
-    if(!isDeleteAll){
-        if(model){
-            model.curUploadStateType = uploadStateSuspend;
-            [uploadingArr addObject:model];
-        }
-    }
-    else
-    {
-        if (!_databaseArr || _databaseArr.count != 3) {
-            return;
-        }
-        uploadingArr = _databaseArr[0];
-        for (uploadFileDataModel*preModel in uploadingArr) {
-            preModel.curUploadStateType = uploadStateSuspend;
-        }
-    }
-    
-    if(uploadingArr.count > 0){
-        //更新数据库
-        [uploadFileDataModel bg_saveOrUpdateArrayAsync:uploadingArr complete:^(BOOL isSuccess) {
-            
-        }];
-    }
-    
-    
-}
-
-- (NSMutableArray*)uploadingArr
-{
-    if(_databaseArr && _databaseArr.count == 3){
-        NSMutableArray *uploadingArr = _databaseArr[0];
-        return uploadingArr;
-    }
-    
-    return [NSMutableArray new];
-}
-
-
-//网络失败后任务暂时保存
-- (void)saveUploadingTaskByNetWorkErrorFun
-{
-    HLog(@"hxd saveUploadingTaskByNetWorkErrorFun")
-   
-    if(self.uploadingArr.count > 0){
-        [[nasMixUploadManager shareManager] cancelUploadAllTaskFun];
-        _needToReUploadTaskType = YES;
-    }
-}
-
-//重新上传网络失败的任务
-- (void)reUploadFileFunByNetWork
-{
-    [nasUploadFileManager shareInstance].needToReUploadTaskType = NO;
-    HLog(@"reUploadFileFunByNetWork")
-    //[cachesFileManager writeLogsWithMsg:@"reUploadFileFunByNetWork"];
-    if(self.uploadingArr.count >0 && _databaseArr.count == 3){
-        
-//        NSMutableArray* doneArr = _databaseArr[1];
-//        NSMutableArray* failArr = _databaseArr[2];
-//        
-//        NSString *logstr = [[NSString alloc] initWithFormat:@"ing:%ld,done:%ld,fail:%ld",self.uploadingArr.count,doneArr.count,failArr.count];
-//        
-//        [cachesFileManager writeLogsWithMsg:logstr];
-        
-        //1.修改状态从失败改为上传中
-//        for (uploadFileDataModel * model in _netWorkFailSaveArr) {
-//            model.curUploadStateType = uploadStateUploading;
-////            for (uploadFileDataModel * uploadingModel in self.uploadingArr){
-////               if (model.bg_id.integerValue == uploadingModel.bg_id.integerValue) {
-////                   uploadingModel.curUploadStateType = uploadStateUploading;
-////                   continue;
-////               }
-////           }
-//        }
-        
-        //2、保存到数控库
-//        [uploadFileDataModel bg_saveOrUpdateArrayAsync:_netWorkFailSaveArr complete:^(BOOL isSuccess) {
-//            
-//        }];
-        
-        //3.判断是否可以上传
-        BOOL isCanUseCellular = [HWDataManager getBoolWithKey:stringKeyAddSn(Const_file_Transfe_canUse_Cellular_all)];
-        if(!isCanUseCellular){//不允许流量上传
-            //
-            if([AFNetworkReachabilityManager sharedManager].networkReachabilityStatus == AFNetworkReachabilityStatusReachableViaWWAN){
-                return;
-            }
-            
-        }
-        
-        //4.重新开始上传
-        [[nasMixUploadManager shareManager] addUploadWithModels:self.uploadingArr];
-    }
-}
-@end

+ 20 - 0
创维盒子/双子星云手机.xcodeproj/project.pbxproj

@@ -397,6 +397,10 @@
 		6B304EA52BEF6944004F5580 /* SystemConfiguration.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 6B304E9F2BEF68DB004F5580 /* SystemConfiguration.framework */; };
 		6B304EA62BEF6954004F5580 /* CoreGraphics.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 6B304EA12BEF68F1004F5580 /* CoreGraphics.framework */; };
 		6B304EA72BEF6967004F5580 /* CoreTelephony.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 6B304EA32BEF6911004F5580 /* CoreTelephony.framework */; };
+		6B32F25C2D94E9F800C713D9 /* DocumentPickerManager.h in Headers */ = {isa = PBXBuildFile; fileRef = 6B32F2592D94E9F800C713D9 /* DocumentPickerManager.h */; };
+		6B32F25D2D94E9F800C713D9 /* DocumentPickerManager.m in Sources */ = {isa = PBXBuildFile; fileRef = 6B32F25A2D94E9F800C713D9 /* DocumentPickerManager.m */; };
+		6B32F25E2D94E9F800C713D9 /* DocumentPickerManager.m in Sources */ = {isa = PBXBuildFile; fileRef = 6B32F25A2D94E9F800C713D9 /* DocumentPickerManager.m */; };
+		6B32F25F2D94E9F800C713D9 /* DocumentPickerManager.h in Headers */ = {isa = PBXBuildFile; fileRef = 6B32F2592D94E9F800C713D9 /* DocumentPickerManager.h */; };
 		6B34DC4D2BF1BA11002DD1EF /* previewImageOrVideoViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 6B34DC4C2BF1BA11002DD1EF /* previewImageOrVideoViewController.m */; };
 		6B34DC4E2BF1BA11002DD1EF /* previewImageOrVideoViewController.h in Headers */ = {isa = PBXBuildFile; fileRef = 6B34DC4B2BF1BA11002DD1EF /* previewImageOrVideoViewController.h */; };
 		6B34DC4F2BF1BA11002DD1EF /* previewImageOrVideoViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 6B34DC4C2BF1BA11002DD1EF /* previewImageOrVideoViewController.m */; };
@@ -1736,6 +1740,8 @@
 		6B304E9F2BEF68DB004F5580 /* SystemConfiguration.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = SystemConfiguration.framework; path = System/Library/Frameworks/SystemConfiguration.framework; sourceTree = SDKROOT; };
 		6B304EA12BEF68F1004F5580 /* CoreGraphics.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreGraphics.framework; path = System/Library/Frameworks/CoreGraphics.framework; sourceTree = SDKROOT; };
 		6B304EA32BEF6911004F5580 /* CoreTelephony.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreTelephony.framework; path = System/Library/Frameworks/CoreTelephony.framework; sourceTree = SDKROOT; };
+		6B32F2592D94E9F800C713D9 /* DocumentPickerManager.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = DocumentPickerManager.h; sourceTree = "<group>"; };
+		6B32F25A2D94E9F800C713D9 /* DocumentPickerManager.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = DocumentPickerManager.m; sourceTree = "<group>"; };
 		6B34DC4B2BF1BA11002DD1EF /* previewImageOrVideoViewController.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = previewImageOrVideoViewController.h; sourceTree = "<group>"; };
 		6B34DC4C2BF1BA11002DD1EF /* previewImageOrVideoViewController.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = previewImageOrVideoViewController.m; sourceTree = "<group>"; };
 		6B34DC642BF1FFB1002DD1EF /* imageCollectionViewCell.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = imageCollectionViewCell.h; sourceTree = "<group>"; };
@@ -2920,6 +2926,15 @@
 			path = ZFPlayer;
 			sourceTree = "<group>";
 		};
+		6B32F25B2D94E9F800C713D9 /* DocumentPickerManager */ = {
+			isa = PBXGroup;
+			children = (
+				6B32F2592D94E9F800C713D9 /* DocumentPickerManager.h */,
+				6B32F25A2D94E9F800C713D9 /* DocumentPickerManager.m */,
+			);
+			path = DocumentPickerManager;
+			sourceTree = "<group>";
+		};
 		6B34DC4A2BF1B9F2002DD1EF /* previewFile */ = {
 			isa = PBXGroup;
 			children = (
@@ -3184,6 +3199,7 @@
 		6B5D86632C227C4A008D25EA /* NAS */ = {
 			isa = PBXGroup;
 			children = (
+				6B32F25B2D94E9F800C713D9 /* DocumentPickerManager */,
 				6BDB85B42D572FDC00526D1F /* BoxHeartbeatAlertTool */,
 				6BF62B122D55D57700E7A98A /* model */,
 				6BB573312C8076A600713351 /* nasBackupsManager */,
@@ -4090,6 +4106,7 @@
 				6B9354952BF33F2700AA8D31 /* editShareView.h in Headers */,
 				184C8AD52A949D5900F26650 /* AboutViewController.h in Headers */,
 				6B34DC672BF1FFB1002DD1EF /* imageCollectionViewCell.h in Headers */,
+				6B32F25C2D94E9F800C713D9 /* DocumentPickerManager.h in Headers */,
 				6BC7413A2C23C8870049BA8D /* cloudPhoneViewController.h in Headers */,
 				6B2C1E602C070ADE00FDCF82 /* ZFKVOController.h in Headers */,
 				6B0581A22AFCF50300D37290 /* AJPhotoListCell.h in Headers */,
@@ -4372,6 +4389,7 @@
 				6B9354962BF33F2700AA8D31 /* editShareView.h in Headers */,
 				6BD506F22B9576A4006E7CB0 /* AboutViewController.h in Headers */,
 				6B34DC692BF1FFB1002DD1EF /* imageCollectionViewCell.h in Headers */,
+				6B32F25F2D94E9F800C713D9 /* DocumentPickerManager.h in Headers */,
 				6BC7413C2C23C8870049BA8D /* cloudPhoneViewController.h in Headers */,
 				6B2C1E612C070ADE00FDCF82 /* ZFKVOController.h in Headers */,
 				6BD506F32B9576A4006E7CB0 /* AJPhotoListCell.h in Headers */,
@@ -5025,6 +5043,7 @@
 				6BD507C62B9576A4006E7CB0 /* GuideView.m in Sources */,
 				6BD507C72B9576A4006E7CB0 /* ShortcutManager.m in Sources */,
 				6BD507C82B9576A4006E7CB0 /* uploadFileRecordViewController.m in Sources */,
+				6B32F25E2D94E9F800C713D9 /* DocumentPickerManager.m in Sources */,
 				6BD507C92B9576A4006E7CB0 /* BaseModel.m in Sources */,
 				6B467BBA2BC7F7D70039A6A6 /* fileUploadToFileCenterModel.m in Sources */,
 				6B4C0F862C0315880070EF2E /* audioPlayerViewController.m in Sources */,
@@ -5389,6 +5408,7 @@
 				18963B472AB84398006E7C50 /* GuideView.m in Sources */,
 				18FCE5452AD136FF0020F623 /* ShortcutManager.m in Sources */,
 				6B0582812B01C67400D37290 /* uploadFileRecordViewController.m in Sources */,
+				6B32F25D2D94E9F800C713D9 /* DocumentPickerManager.m in Sources */,
 				A003F6A827D841C800715CBF /* BaseModel.m in Sources */,
 				6B467BB82BC7F7D70039A6A6 /* fileUploadToFileCenterModel.m in Sources */,
 				6B4C0F852C0315880070EF2E /* audioPlayerViewController.m in Sources */,