Browse Source

下载文件处理

Steven 1 year ago
parent
commit
36ab2b2207

+ 6 - 6
KulexiuForTeacher/KulexiuForTeacher/Common/Base/KSAccompanyWebViewController.m

@@ -631,7 +631,7 @@
                 NSInteger reportInterval = [content ks_integerValueForKey:@"interval"];
                 // 下载midi文件
                 BOOL hasSaveSong = [self checkSongHasSaveWithSongUrl:midiUrl];
-                NSString *fileName = [[midiUrl componentsSeparatedByString:@"/"] lastObject];
+                NSString *fileName = [midiUrl getUrlFileName];
                 NSString *filePath = [self getFilePathWithName:fileName];
                 if (hasSaveSong) {
                     [self configPlayerEngineWithSong:filePath reportTime:reportInterval];
@@ -814,7 +814,7 @@
                 NSDictionary *content = [parm ks_dictionaryValueForKey:@"content"];
                 NSString *accompanyUrl = [content ks_stringValueForKey:@"accompanyUrl"];
                 if (![NSString isEmptyString:accompanyUrl]) {
-                    NSString *fileName = [[accompanyUrl componentsSeparatedByString:@"/"] lastObject];
+                    NSString *fileName = [accompanyUrl getUrlFileName];
                     NSString *filePath = [self getAccompanyFilePathWithName:fileName];
                     NSURL *fileUrl = [[NSURL alloc] initFileURLWithPath:filePath];
                     self.accompanyUrl = accompanyUrl;
@@ -1047,7 +1047,7 @@
     }else{
         NSLog(@"已创建文件夹");
     }
-    NSString *fileName = [[midiUrl componentsSeparatedByString:@"/"] lastObject];
+    NSString *fileName = [midiUrl getUrlFileName];
     NSString *tempPath = [filePath stringByAppendingPathComponent:fileName];
     BOOL success = [sourceData writeToFile:tempPath atomically:NO];
     return success;
@@ -1061,7 +1061,7 @@
 
 - (BOOL)checkSongHasSaveWithSongUrl:(NSString *)songUrl {
     BOOL hasSaveFile = NO;
-    NSString *fileName = [[songUrl componentsSeparatedByString:@"/"] lastObject];
+    NSString *fileName = [songUrl getUrlFileName];
     NSString *filePath = [self getFilePathWithName:fileName];
     
     NSFileManager *fileManager = [NSFileManager defaultManager];
@@ -1574,7 +1574,7 @@
     }else{
         NSLog(@"已创建文件夹");
     }
-    NSString *fileName = [[accompanyUrl componentsSeparatedByString:@"/"] lastObject];
+    NSString *fileName = [accompanyUrl getUrlFileName];
     NSString *tempPath = [filePath stringByAppendingPathComponent:fileName];
     BOOL success = [sourceData writeToFile:tempPath atomically:NO];
     return success;
@@ -1587,7 +1587,7 @@
 
 - (BOOL)checkSongHasSaveAccompanyWithSongUrl:(NSString *)songUrl {
     BOOL hasSaveFile = NO;
-    NSString *fileName = [[songUrl componentsSeparatedByString:@"/"] lastObject];
+    NSString *fileName = [songUrl getUrlFileName];
     NSString *filePath = [self getAccompanyFilePathWithName:fileName];
     
     NSFileManager *fileManager = [NSFileManager defaultManager];

+ 1 - 0
KulexiuForTeacher/KulexiuForTeacher/Common/MediaMerge/AudioMerge/KSMediaMergeView.m

@@ -595,6 +595,7 @@
         {
             // 暂停播放
             [self stopPlay];
+            self.isChooseVideoCover = NO;
             // 调用相册
             self.mediaManager = [[KSMediaManager alloc] init];
             self.mediaManager.mediaType = MEDIATYPE_PHOTO;

+ 2 - 1
KulexiuForTeacher/KulexiuForTeacher/Common/Tools/Extension/NSString+Extension.h

@@ -32,7 +32,8 @@ typedef NS_ENUM(NSInteger,CHECKTYPE){
 - (NSString *)dateFormatString; // 返回年月日 传入格式 YYYY-MM-dd hh:mm:ss
 // url encoding
 - (NSString *)getUrlEndcodeString;
-
+// 获取保存文件名
+- (NSString *)getUrlFileName;
 /**
  获取字符串首字母(传入汉字字符串,返回大写拼音首字母)
 

+ 8 - 0
KulexiuForTeacher/KulexiuForTeacher/Common/Tools/Extension/NSString+Extension.m

@@ -239,6 +239,14 @@
     return [url stringByAddingPercentEncodingWithAllowedCharacters:[NSCharacterSet URLQueryAllowedCharacterSet]];;
 }
 
+// 获取保存文件名
+- (NSString *)getUrlFileName {
+    NSString *fileName = [[self componentsSeparatedByString:@"/"] lastObject];
+    if ([fileName containsString:@"?"]) {
+        fileName = [[fileName componentsSeparatedByString:@"?"] firstObject];
+    }
+    return fileName;
+}
 
 /**
  获取字符串首字母(传入汉字字符串,返回大写拼音首字母)

+ 6 - 0
KulexiuForTeacher/KulexiuForTeacher/Common/Tools/VoNetworking/Cache/VoCacheManager.m

@@ -105,6 +105,9 @@ static NSTimeInterval cacheTime = 7 * 24 * 60 * 60;
     strArray = [requestUrl componentsSeparatedByString:@"."];
     if (strArray.count > 0) {
         type = strArray[strArray.count - 1];
+        if ([type containsString:@"?"]) {
+            type = [[type componentsSeparatedByString:@"?"] firstObject];
+        }
     }
     
     if (type) {
@@ -132,6 +135,9 @@ static NSTimeInterval cacheTime = 7 * 24 * 60 * 60;
     strArray = [requestUrl componentsSeparatedByString:@"."];
     if (strArray.count > 0) {
         type = strArray[strArray.count - 1];
+        if ([type containsString:@"?"]) {
+            type = [[type componentsSeparatedByString:@"?"] firstObject];
+        }
     }
     
     if (type) {