Преглед на файлове

1.下载保存相关(文件类型以及未保存的下次打开保存)

huangxiaodong преди 10 месеца
родител
ревизия
8f0e2ae8dc

+ 2 - 0
创维盒子/双子星云手机/Class/Set/uploadFile/customDownloadManager/customDownloadCacheManager.h

@@ -32,6 +32,8 @@ NS_ASSUME_NONNULL_BEGIN
 
 + (NSString *)getFullDirector;
 
+/**  上传的fullPath 是不能用的 要改新的*/
++ (NSString *)getFullPathByOldFullPath:(NSString*)fullPath;
 
 @end
 

+ 24 - 0
创维盒子/双子星云手机/Class/Set/uploadFile/customDownloadManager/customDownloadCacheManager.m

@@ -20,6 +20,10 @@ static NSMutableDictionary *_downloadList;
     if (account.length != 0)
     {
          NSString *fileFolder = [HWDataManager documentPathForAccount:account fileFolder:KCustomDownloadDirector];
+        // 创建文件储存路径
+        if (![[NSFileManager defaultManager] fileExistsAtPath:fileFolder]) {
+            [[NSFileManager defaultManager] createDirectoryAtPath:fileFolder withIntermediateDirectories:YES attributes:nil error:nil];
+        }
          return fileFolder;
      }else {
          HLog(@"创建下载plist文件失败!");
@@ -27,6 +31,26 @@ static NSMutableDictionary *_downloadList;
      }
 }
 
+/**  上传的fullPath 是不能用的 要改新的*/
++ (NSString *)getFullPathByOldFullPath:(NSString*)fullPath
+{
+    NSArray *pathArr= [fullPath componentsSeparatedByString:@"/"];
+    NSString * fileName= @"";
+    
+    if(pathArr && pathArr.count >0){
+        fileName = pathArr.lastObject;
+    }
+    else{
+        return @"";
+    }
+    
+    NSString* fileFullDir = [customDownloadCacheManager getFullDirector];
+    NSString* curFullPath = [fileFullDir stringByAppendingPathComponent:fileName];
+    
+    return curFullPath;
+}
+
+
 /**  查询当前文件下载了多少 */
 + (int64_t)getFileSizeWithURL:(NSString *)url
 {

+ 2 - 1
创维盒子/双子星云手机/Class/Set/uploadFile/uploadFileManager/boxDownloadFileManager.m

@@ -637,8 +637,9 @@ static boxDownloadFileManager * cur_boxDownloadFileShareInstance = nil;
             NSDictionary*dict = dictM[key];
             customDownloadOperation *model = [customDownloadOperation mj_objectWithKeyValues:dict];
             
+            NSString*curFullPath = [customDownloadCacheManager getFullPathByOldFullPath:model.fullPath];
             //判断文件是否还存在
-            if (![[NSFileManager defaultManager] fileExistsAtPath:model.fullPath]) {
+            if (![[NSFileManager defaultManager] fileExistsAtPath:curFullPath]) {
                 //不存在 删除信息
                 [self deleteFileInfoWithUrl:key];
             }

+ 2 - 1
创维盒子/双子星云手机/NAS/nasDownloadManager/nasDownloadFileManager.m

@@ -640,8 +640,9 @@ static nasDownloadFileManager * cur_nasDownloadFileManager = nil;
             NSDictionary*dict = dictM[key];
             customDownloadOperation *model = [customDownloadOperation mj_objectWithKeyValues:dict];
             
+            NSString*curFullPath = [customDownloadCacheManager getFullPathByOldFullPath:model.fullPath];
             //判断文件是否还存在
-            if (![[NSFileManager defaultManager] fileExistsAtPath:model.fullPath]) {
+            if (![[NSFileManager defaultManager] fileExistsAtPath:curFullPath]) {
                 //不存在 删除信息
                 [self deleteFileInfoWithUrl:key];
             }

+ 2 - 0
创维盒子/双子星云手机/cloudPhone/websocket/webSocketManager+downloadFile.m

@@ -338,6 +338,8 @@
 - (void)checkSaveNasFileAgainFun
 {
     [[boxDownloadFileManager shareInstance] checkDownloadDonePlistInfoFun];
+    
+    [[nasDownloadFileManager shareInstance] checkDownloadDonePlistInfoFun];
 }
 
 #pragma mark 再次读取ws下载完成数据做保存操作

+ 6 - 4
创维盒子/双子星云手机/cloudPhone/websocket/webSocketManager+downloadNasFile.m

@@ -29,12 +29,14 @@
 #pragma mark 下载完后处理保持流程
 - (void)handldDownloadDoneToSaveBy:(customDownloadOperation*)model{
     //解码
-    NSString * urlString = [model.url stringByReplacingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
+    NSString * urlString = [model.url stringByRemovingPercentEncoding];
+    //[model.url stringByReplacingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
     NSArray *nameArr= [urlString componentsSeparatedByString:@"."];
-    NSString * pathStr= model.fullPath;
-    NSString * decodePathStr= [pathStr stringByReplacingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
     
-    HLog(@"downloadNasFile:%@\n%@\n%@",urlString,pathStr,[pathStr stringByReplacingPercentEscapesUsingEncoding:NSUTF8StringEncoding])
+    NSString * pathStr= [customDownloadCacheManager getFullPathByOldFullPath:model.fullPath];
+    NSString * decodePathStr= [pathStr stringByRemovingPercentEncoding];
+    
+    HLog(@"downloadNasFile:%@\n%@\n%@",urlString,pathStr,[pathStr stringByRemovingPercentEncoding])
     
     if(![pathStr isEqualToString:decodePathStr]){
         // 尝试移动(即重命名)文件

+ 1 - 0
创维盒子/双子星云手机/cloudPhone/websocket/webSocketManager.h

@@ -25,6 +25,7 @@
 #import "boxDownloadFileManager.h"
 #import "DFPlayer.h"
 #import "audioPlayingView.h"
+#import "nasDownloadFileManager.h"
 
 NS_ASSUME_NONNULL_BEGIN