Przeglądaj źródła

Merge branch 'upload' into NewDev

Steven 2 miesięcy temu
rodzic
commit
1ea74ef9ea

+ 22 - 18
KulexiuForTeacher/KulexiuForTeacher/Common/Base/WebView/KSBaseWKWebViewController.m

@@ -71,6 +71,8 @@ typedef NS_ENUM(NSInteger, CHOOSETYPE) {
 
 @property (nonatomic, strong) NSString *bucketName;
 
+@property (nonatomic, strong) NSString *bucketPath;
+
 @property (nonatomic, assign) BOOL isFirstLoad;
 
 @property (nonatomic, strong) KSWebLoadRefreshView *errorView;
@@ -488,7 +490,8 @@ typedef NS_ENUM(NSInteger, CHOOSETYPE) {
         NSString *typeStr = [valueDic ks_stringValueForKey:@"type"];
         NSInteger maxCount = [valueDic ks_integerValueForKey:@"max"];
         NSString *bucket = [valueDic ks_stringValueForKey:@"bucket"];
-        [self chooseFileWithType:typeStr maxNumber:maxCount bucket:bucket];
+        NSString *path = [valueDic ks_stringValueForKey:@"path"];
+        [self chooseFileWithType:typeStr maxNumber:maxCount bucket:bucket path:path];
         
     }
     else if ([[parm ks_stringValueForKey:@"api"] isEqualToString:@"setAddress"]) { // 跳转地址选择
@@ -895,7 +898,7 @@ typedef NS_ENUM(NSInteger, CHOOSETYPE) {
     NSString *fileName = @"videoCoverImage";
     
     [LOADING_MANAGER showCustomLoading:@"上传中..."];
-    [UPLOAD_MANAGER configWithfilePath:@"/user/"];
+    [UPLOAD_MANAGER configWithfilePath:@"/production/"];
     [UPLOAD_MANAGER uploadFile:imgData fileName:fileName fileSuffix:[UIImage typeForImageData:imgData] progress:^(int64_t bytesWritten, int64_t totalBytes) {
         // 显示进度
         int progress = (int)(bytesWritten / totalBytes * 100);
@@ -1016,32 +1019,33 @@ typedef NS_ENUM(NSInteger, CHOOSETYPE) {
     [self postMessage:sendParm];
 }
 
-- (void)chooseFileWithType:(NSString *)typeStr maxNumber:(NSInteger)maxCount bucket:(NSString *)bucket {
+- (void)chooseFileWithType:(NSString *)typeStr maxNumber:(NSInteger)maxCount bucket:(NSString *)bucket path:(NSString *)path {
     if ([typeStr isEqualToString:@"img"]) { // 选择图片上传
         if (maxCount > 9) {
             maxCount = 9;
         }
-        [self chooseMediaWithType:MEDIATYPE_PHOTO maxCount:maxCount bucket:bucket];
+        [self chooseMediaWithType:MEDIATYPE_PHOTO maxCount:maxCount bucket:bucket path:path];
     }
     else if ([typeStr isEqualToString:@"video"]) {
-        [self chooseMediaWithType:MEDIATYPE_VIDEO maxCount:1 bucket:bucket];
+        [self chooseMediaWithType:MEDIATYPE_VIDEO maxCount:1 bucket:bucket path:path];
     }
     else if ([typeStr isEqualToString:@"file"]) {
-        [self chooseDocumentWithType:CHOOSETYPE_ALL bucket:bucket];
+        [self chooseDocumentWithType:CHOOSETYPE_ALL bucket:bucket path:path];
     }
     else if ([typeStr isEqualToString:@"midi"]) {
-        [self chooseDocumentWithType:CHOOSETYPE_MIDI bucket:bucket];
+        [self chooseDocumentWithType:CHOOSETYPE_MIDI bucket:bucket path:path];
     }
     else if ([typeStr isEqualToString:@"mp3"]) {
-        [self chooseDocumentWithType:CHOOSETYPE_MP3 bucket:bucket];
+        [self chooseDocumentWithType:CHOOSETYPE_MP3 bucket:bucket path:path];
     }
     else if ([typeStr isEqualToString:@"xml"] || [typeStr isEqualToString:@"musicxml"]) {
-        [self chooseDocumentWithType:CHOOSETYPE_XML bucket:bucket];
+        [self chooseDocumentWithType:CHOOSETYPE_XML bucket:bucket path:path];
     }
 }
 
-- (void)chooseDocumentWithType:(CHOOSETYPE)fileTyle bucket:(NSString *)bucket {
+- (void)chooseDocumentWithType:(CHOOSETYPE)fileTyle bucket:(NSString *)bucket path:(NSString *)path {
     self.bucketName = bucket;
+    self.bucketPath = path;
     self.fileChooseType = fileTyle;
     NSArray *documentTypes = @[@"public.content", @"public.text", @"public.source-code", @"public.image", @"public.audio", @"public.audiovisual-content", @"com.adobe.pdf", @"com.apple.keynote.key", @"com.microsoft.word.doc", @"com.microsoft.excel.xls", @"com.microsoft.powerpoint.ppt"];
     KSDocumentViewController *documentPickerViewController = [[KSDocumentViewController alloc] initWithDocumentTypes:documentTypes inMode:UIDocumentPickerModeImport];
@@ -1052,7 +1056,7 @@ typedef NS_ENUM(NSInteger, CHOOSETYPE) {
     [self presentViewController:documentPickerViewController animated:YES completion:nil];
 }
 
-- (void)chooseMediaWithType:(MEDIATYPE)type maxCount:(NSInteger)maxCount bucket:(NSString *)bucketName {
+- (void)chooseMediaWithType:(MEDIATYPE)type maxCount:(NSInteger)maxCount bucket:(NSString *)bucketName path:(NSString *)path {
     self.mediaManager = [[KSMediaManager alloc] init];
     self.mediaManager.mediaType = type;
     self.mediaManager.maxPhotoNumber = maxCount;
@@ -1063,12 +1067,12 @@ typedef NS_ENUM(NSInteger, CHOOSETYPE) {
     [self.mediaManager noAlertCallback:^(NSString * _Nullable videoUrl, NSMutableArray * _Nullable imageArray, NSMutableArray * _Nullable imageAsset) {
         
         if (type == MEDIATYPE_PHOTO) {
-            [weakSelf uploadImageArray:imageArray bucket:bucketName];
+            [weakSelf uploadImageArray:imageArray bucket:bucketName path:path];
         }
         else {
             NSLog(@"%@", videoUrl);
             // 上传视频
-            [weakSelf uploadVideoWithUrl:videoUrl bucket:bucketName];
+            [weakSelf uploadVideoWithUrl:videoUrl bucket:bucketName path:path];
         }
      
     }];
@@ -1604,14 +1608,14 @@ typedef NS_ENUM(NSInteger, CHOOSETYPE) {
         return [[NSMutableAttributedString alloc] initWithString:@""];
     }
 }
-- (void)uploadImageArray:(NSMutableArray *)imageArray bucket:(NSString *)bucket {
+- (void)uploadImageArray:(NSMutableArray *)imageArray bucket:(NSString *)bucket path:(NSString *)path {
     [LOADING_MANAGER showCustomLoading:@"加载中..."];
     NSMutableArray *imageDataArray = [NSMutableArray array];
     for (UIImage *image in imageArray) {
         NSData *imgData = [UIImage turnsImaegDataByImage:image];
         [imageDataArray addObject:imgData];
     }
-    [UPLOAD_MANAGER configWithfilePath:@"/user/"];
+    [UPLOAD_MANAGER configWithfilePath:path];
     [UPLOAD_MANAGER mutilUploadImage:imageDataArray fileName:@"complainImg" successCallback:^(NSMutableArray * _Nonnull fileUrlArray) {
         [LOADING_MANAGER removeCustomLoading];
         NSMutableArray *urlArray = [NSMutableArray array];
@@ -1634,14 +1638,14 @@ typedef NS_ENUM(NSInteger, CHOOSETYPE) {
 }
 
 #pragma mark --- 上传视频文件
-- (void)uploadVideoWithUrl:(NSString *)videoUrl bucket:(NSString *)bucket {
+- (void)uploadVideoWithUrl:(NSString *)videoUrl bucket:(NSString *)bucket path:(NSString *)path {
     // 取出视频第一帧
     UIImage *previewImage = [self firstFrameWithVideoURL:[NSURL fileURLWithPath:videoUrl] size:CGSizeMake(1280, 720)];
     __block NSString *imageUrl = @"";
     if (previewImage) { // 如果有第一帧
         NSData *imgData = [UIImage turnsImaegDataByImage:previewImage];
         NSString *fileName = @"videoPreviewImg";
-        [UPLOAD_MANAGER configWithfilePath:@"klx"];
+        [UPLOAD_MANAGER configWithfilePath:path];
         [UPLOAD_MANAGER uploadImage:imgData fileName:fileName successCallback:^(NSMutableArray * _Nonnull fileUrlArray) {
             NSString *url = [fileUrlArray lastObject];
             imageUrl = url;
@@ -1885,7 +1889,7 @@ typedef NS_ENUM(NSInteger, CHOOSETYPE) {
         [LOADING_MANAGER showCustomLoading:@"加载中..."];
         NSString *suffix = [NSString stringWithFormat:@".%@",[[fileName componentsSeparatedByString:@"."] lastObject]];
         NSData *fileData = [NSData dataWithContentsOfURL:[NSURL fileURLWithPath:fileUrl]];
-        [UPLOAD_MANAGER configWithfilePath:@"/user/"];
+        [UPLOAD_MANAGER configWithfilePath:self.bucketPath];
         [UPLOAD_MANAGER uploadFile:fileData fileName:@"file" fileSuffix:suffix progress:^(int64_t bytesWritten, int64_t totalBytes) {
             
         } successCallback:^(NSMutableArray * _Nonnull fileUrlArray) {

+ 4 - 4
KulexiuForTeacher/KulexiuForTeacher/Common/MediaMerge/AudioMerge/KSMediaMergeView.m

@@ -952,7 +952,7 @@
     if (self.settingImage) {
         NSData *imgData = [UIImage turnsImaegDataByImage:self.settingImage];
         NSString *fileName = @"musicCoverImg";
-        [UPLOAD_MANAGER configWithfilePath:@"/user/"];
+        [UPLOAD_MANAGER configWithfilePath:@"/production/"];
         [UPLOAD_MANAGER uploadImage:imgData fileName:fileName successCallback:^(NSMutableArray * _Nonnull fileUrlArray) {
             NSString *avatarUrl = [fileUrlArray lastObject];
             self.coverImage = avatarUrl;
@@ -973,7 +973,7 @@
     if (self.videoCoverImage) {
         NSData *imgData = [UIImage turnsImaegDataByImage:self.videoCoverImage];
         NSString *fileName = @"musicCoverImg";
-        [UPLOAD_MANAGER configWithfilePath:@"/user/"];
+        [UPLOAD_MANAGER configWithfilePath:@"/production/"];
         [UPLOAD_MANAGER uploadImage:imgData fileName:fileName successCallback:^(NSMutableArray * _Nonnull fileUrlArray) {
             NSString *avatarUrl = [fileUrlArray lastObject];
             self.videoCoverUrl = avatarUrl;
@@ -1533,7 +1533,7 @@
     [LOADING_MANAGER showProgressLoading:tips progress:beginProgress];
     NSData *fileData = [NSData dataWithContentsOfURL:fileUrl];
     NSString *suffix = [NSString stringWithFormat:@".%@",[fileUrl pathExtension]];
-    [UPLOAD_MANAGER configWithfilePath:@"/user/"];
+    [UPLOAD_MANAGER configWithfilePath:@"/production/"];
     [UPLOAD_MANAGER videoUpload:fileData fileName:@"video" fileSuffix:suffix progress:^(int64_t bytesWritten, int64_t totalBytes) {
         // 显示进度
         float progress = (bytesWritten*1.0 / totalBytes) * rate + beginProgress;
@@ -1566,7 +1566,7 @@
     [LOADING_MANAGER showProgressLoading:tips progress:beginProgress];
     NSData *fileData = [NSData dataWithContentsOfURL:fileUrl];
     NSString *suffix = [NSString stringWithFormat:@".%@",[fileUrl pathExtension]];
-    [UPLOAD_MANAGER configWithfilePath:@"/user/"];
+    [UPLOAD_MANAGER configWithfilePath:@"/production/"];
     [UPLOAD_MANAGER uploadFile:fileData fileName:@"evaluateAudio" fileSuffix:suffix progress:^(int64_t bytesWritten, int64_t totalBytes) {
         // 显示进度
         float progress = (bytesWritten*1.0 / totalBytes) * rate + beginProgress;

+ 1 - 1
KulexiuForTeacher/KulexiuForTeacher/Module/Chat/Group/Controller/KSChatComplainController.m

@@ -92,7 +92,7 @@
         NSData *imgData = [UIImage turnsImaegDataByImage:image];
         [imageDataArray addObject:imgData];
     }
-    [UPLOAD_MANAGER configWithfilePath:@"/user/"];
+    [UPLOAD_MANAGER configWithfilePath:@"/feedback/"];
     [UPLOAD_MANAGER mutilUploadImage:imageDataArray fileName:@"complainImg" successCallback:^(NSMutableArray * _Nonnull fileUrlArray) {
         NSMutableArray *urlArray = [NSMutableArray array];
         for (NSString *url in fileUrlArray) {

+ 1 - 1
KulexiuForTeacher/KulexiuForTeacher/Module/Live/Controller/CreateLiveViewController.m

@@ -114,7 +114,7 @@
     UIImage *coverImage = [self.imageArray lastObject];
     NSData *imgData = [UIImage turnsImaegDataByImage:coverImage];
     NSString *fileName = @"image";
-    [UPLOAD_MANAGER configWithfilePath:@"/live/"];
+    [UPLOAD_MANAGER configWithfilePath:@"/course/"];
     [UPLOAD_MANAGER uploadImage:imgData fileName:fileName successCallback:^(NSMutableArray * _Nonnull fileUrlArray) {
         NSString *avatarUrl = [fileUrlArray lastObject];
         [self uploadCoverImage:avatarUrl liveTilte:title content:content];

+ 4 - 4
KulexiuForTeacher/KulexiuForTeacher/Module/Mine/CreateStyle/Controller/MyStyleViewController.m

@@ -427,7 +427,7 @@
     // 上传图片
     NSData *imgData = [UIImage compressImage:firstImage maxLength:5];
     NSString *fileName = @"styleImage";
-    [UPLOAD_MANAGER configWithfilePath:@"/user/"];
+    [UPLOAD_MANAGER configWithfilePath:@"/userStyle/"];
     [UPLOAD_MANAGER uploadImage:imgData fileName:fileName successCallback:^(NSMutableArray * _Nonnull fileUrlArray) {
         NSString *imageUrl = [fileUrlArray lastObject];
         if (self.videoArray.count > index) {
@@ -449,7 +449,7 @@
             // 上传图片
             NSData *imgData = [UIImage compressImage:firstImage maxLength:5];
             NSString *fileName = @"styleImage";
-            [UPLOAD_MANAGER configWithfilePath:@"/user/"];
+            [UPLOAD_MANAGER configWithfilePath:@"/userStyle/"];
             [UPLOAD_MANAGER uploadImage:imgData fileName:fileName successCallback:^(NSMutableArray * _Nonnull fileUrlArray) {
                 NSString *imageUrl = [fileUrlArray lastObject];
                 [self uploadVideoWithUrl:videoUrl coverUrl:imageUrl];
@@ -475,7 +475,7 @@
     NSURL *fileUrl = [NSURL fileURLWithPath:videoUrl];
     NSData *fileData = [NSData dataWithContentsOfURL:fileUrl];
     NSString *suffix = [NSString stringWithFormat:@".%@",[fileUrl pathExtension]];
-    [UPLOAD_MANAGER configWithfilePath:@"/user/"];
+    [UPLOAD_MANAGER configWithfilePath:@"/userStyle/"];
     [UPLOAD_MANAGER videoUpload:fileData fileName:@"video" fileSuffix:suffix progress:^(int64_t bytesWritten, int64_t totalBytes) {
         int progress = (int)(bytesWritten / totalBytes * 100);
         __block NSString *tipsMessage = [NSString stringWithFormat:@"上传中 %d%%",progress];
@@ -742,7 +742,7 @@
 - (void)updateWithUserLogo:(UIImage *)image {
     NSData *imgData = [UIImage turnsImaegDataByImage:image];
     NSString *fileName = @"image";
-    [UPLOAD_MANAGER configWithfilePath:@"/user/"];
+    [UPLOAD_MANAGER configWithfilePath:@"/userStyle/"];
     [UPLOAD_MANAGER uploadImage:imgData fileName:fileName successCallback:^(NSMutableArray * _Nonnull fileUrlArray) {
         NSString *avatarUrl = [fileUrlArray lastObject];
         [self modifyUserMessage:avatarUrl gender:nil];

+ 1 - 1
KulexiuForTeacher/KulexiuForTeacher/Module/Mine/Feedback/Controller/FeedbackViewController.m

@@ -162,7 +162,7 @@
             NSData *imgData = [UIImage turnsImaegDataByImage:image];
             [imageDataArray addObject:imgData];
         }
-        [UPLOAD_MANAGER configWithfilePath:@"/user/"];
+        [UPLOAD_MANAGER configWithfilePath:@"/feedback/"];
         [UPLOAD_MANAGER mutilUploadImage:imageDataArray fileName:@"complainImg" successCallback:^(NSMutableArray * _Nonnull fileUrlArray) {
             NSMutableArray *urlArray = [NSMutableArray array];
             for (NSString *url in fileUrlArray) {

+ 6 - 3
KulexiuForTeacher/KulexiuForTeacher/Module/Mine/Setting/Controller/UserSettingViewController.m

@@ -22,6 +22,7 @@
 #import <RSKImageCropper/RSKImageCropper.h>
 #import <KSSmallChoosePicker.h>
 #import <UIImageView+DisplayImage.h>
+#import "NSDate+Extension.h"
 
 @interface UserSettingViewController ()<RSKImageCropViewControllerDelegate>
 
@@ -194,12 +195,14 @@
 
 - (void)updateWithUserLogo:(UIImage *)image {
     NSData *imgData = [UIImage turnsImaegDataByImage:image];
-    NSString *fileName = @"image";
+    NSString *avatarName = [NSString stringWithFormat:@"%@.png", UserDefault(UIDKey)];
+    
     [UPLOAD_MANAGER configWithfilePath:@"/user/"];
-    [UPLOAD_MANAGER uploadImage:imgData fileName:fileName successCallback:^(NSMutableArray * _Nonnull fileUrlArray) {
+    [UPLOAD_MANAGER uploadFixedNameImage:imgData fileName:avatarName successCallback:^(NSMutableArray * _Nonnull fileUrlArray) {
         NSString *avatarUrl = [fileUrlArray lastObject];
+        avatarUrl = [NSString stringWithFormat:@"%@?t=%@", avatarUrl, [NSDate getCurrentTimestamp]];
         [self modifyUserMessage:avatarUrl gender:nil];
-    } faliure:^(NSError * _Nullable error, NSString *descMessaeg) {
+    } faliure:^(NSError * _Nullable error, NSString * _Nullable descMessaeg) {
         if (![NSString isEmptyString:descMessaeg]) {
             [LOADING_MANAGER MBShowAUTOHidingInWindow:descMessaeg];
         }

+ 1 - 1
KulexiuForTeacher/KulexiuForTeacher/Module/TXClassRoom/Controller/TXClassroomViewController.m

@@ -1940,7 +1940,7 @@
         [imageDataArray addObject:imgData];
     }
     
-    [UPLOAD_MANAGER configWithfilePath:@"/classroom/"];
+    [UPLOAD_MANAGER configWithfilePath:@"/courseSign/"];
     [UPLOAD_MANAGER mutilUploadImage:imageDataArray fileName:@"onlineClassroomImg" successCallback:^(NSMutableArray * _Nonnull fileUrlArray) {
         NSMutableArray *urlArray = [NSMutableArray array];
         for (NSString *url in fileUrlArray) {