瀏覽代碼

Merge branch 'upload' into NewDev

# Conflicts:
#	KulexiuForStudent/KulexiuForStudent/Module/Chat/Group/View/GroupSettingBodyView.m
#	KulexiuForStudent/KulexiuForStudent/Module/Chat/Group/View/GroupSettingBodyView.xib
Steven 6 月之前
父節點
當前提交
0e84a5cb07

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

@@ -69,6 +69,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;
@@ -491,7 +493,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"]) { // 跳转地址选择
         AddressListViewController *ctrl = [[AddressListViewController alloc] init];
@@ -900,7 +903,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);
@@ -988,32 +991,33 @@ typedef NS_ENUM(NSInteger, CHOOSETYPE) {
     [self presentViewController:documentPicker animated:YES completion:nil];
 }
 
-- (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];
@@ -1024,7 +1028,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;
@@ -1035,12 +1039,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];
         }
      
     }];
@@ -1599,14 +1603,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];
@@ -1627,14 +1631,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:@"/user/"];
+        [UPLOAD_MANAGER configWithfilePath:path];
         [UPLOAD_MANAGER uploadImage:imgData fileName:fileName successCallback:^(NSMutableArray * _Nonnull fileUrlArray) {
             NSString *url = [fileUrlArray lastObject];
             imageUrl = url;
@@ -1896,7 +1900,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) {
             int progress = (int)(bytesWritten / totalBytes * 100);
             __block NSString *tipsMessage = [NSString stringWithFormat:@"上传中 %d%%",progress];

+ 4 - 4
KulexiuForStudent/KulexiuForStudent/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;

+ 9 - 7
KulexiuForStudent/KulexiuForStudent/InstitutionModule/Mine/Controller/INSSettingViewController.m

@@ -25,6 +25,7 @@
 
 #import "CoursewareDownloadManager.h"
 #import "KSBaseGuideManager.h"
+#import "NSDate+Extension.h"
 
 @interface INSSettingViewController ()<RSKImageCropViewControllerDelegate>
 
@@ -265,16 +266,17 @@
 
 - (void)updateWithUserLogo:(UIImage *)image {
     NSData *imgData = [UIImage turnsImaegDataByImage:image];
-    NSString *fileName = @"image";
     [UPLOAD_MANAGER configWithfilePath:@"/user/"];
-    [UPLOAD_MANAGER uploadImage:imgData fileName:fileName successCallback:^(NSMutableArray * _Nonnull fileUrlArray) {
+    NSString *avatarName = [NSString stringWithFormat:@"%@.png", UserDefault(UIDKey)];
+    [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 birthday:nil];
-    } faliure:^(NSError * _Nullable error, NSString *descMessaeg) {
-        if (![NSString isEmptyString:descMessaeg]) {
-            [LOADING_MANAGER MBShowAUTOHidingInWindow:descMessaeg];
-        }
-    }];
+        } faliure:^(NSError * _Nullable error, NSString * _Nullable descMessaeg) {
+            if (![NSString isEmptyString:descMessaeg]) {
+                [LOADING_MANAGER MBShowAUTOHidingInWindow:descMessaeg];
+            }
+        }];
 }
 
 - (void)modifyUserMessage:(NSString *)imgUrl gender:(NSString *)gender birthday:(NSString *)birthday {

+ 1 - 1
KulexiuForStudent/KulexiuForStudent/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) {

+ 0 - 1
KulexiuForStudent/KulexiuForStudent/Module/Chat/Group/View/GroupSettingBodyView.m

@@ -168,7 +168,6 @@ typedef void(^ChooseMemberCallback)(NSString *targetId);
             groupLimit = 2000;
         }
         self.groupMemberDesc.text = [NSString stringWithFormat:@"%.0f/%zd",model.memberNum,groupLimit];
-        
         if ([NSString isEmptyString:model.introduce]) {
             self.groupDesc.text = @"暂无群简介";
         }

+ 1 - 1
KulexiuForStudent/KulexiuForStudent/Module/Chat/Group/View/GroupSettingBodyView.xib

@@ -413,7 +413,7 @@
             <nil key="simulatedBottomBarMetrics"/>
             <freeformSimulatedSizeMetrics key="simulatedDestinationMetrics"/>
             <connections>
-                <outlet property="groupDesc" destination="fEO-Ri-MQX" id="9vr-Iy-30o"/>
+                <outlet property="groupDesc" destination="fEO-Ri-MQX" id="NcA-Yx-KMM"/>
                 <outlet property="groupImage" destination="Pgc-8e-F0o" id="cD2-2v-pf4"/>
                 <outlet property="groupMemberDesc" destination="mGj-Ko-LcU" id="oD7-d5-0hD"/>
                 <outlet property="groupName" destination="hDS-dB-bma" id="Rpk-gW-4hb"/>

+ 1 - 1
KulexiuForStudent/KulexiuForStudent/Module/Course/AccompanyCourse/Controller/AccompanyDetailViewController.m

@@ -344,7 +344,7 @@
     NSURL *uploadFileUrl = [NSURL fileURLWithPath:videoUrl];
     NSData *fileData = [NSData dataWithContentsOfURL:uploadFileUrl];
     NSString *suffix = [NSString stringWithFormat:@".%@",[uploadFileUrl pathExtension]];
-    [UPLOAD_MANAGER configWithfilePath:@"homework"];
+    [UPLOAD_MANAGER configWithfilePath:@"/homework/"];
     [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];

+ 1 - 1
KulexiuForStudent/KulexiuForStudent/Module/Course/VipCourse/Controller/VipCouseDetailViewController.m

@@ -350,7 +350,7 @@
     NSURL *uploadFileUrl = [NSURL fileURLWithPath:videoUrl];
     NSData *fileData = [NSData dataWithContentsOfURL:uploadFileUrl];
     NSString *suffix = [NSString stringWithFormat:@".%@",[uploadFileUrl pathExtension]];
-    [UPLOAD_MANAGER configWithfilePath:@"homework"];
+    [UPLOAD_MANAGER configWithfilePath:@"/homework/"];
     [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];

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

@@ -184,7 +184,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) {

+ 5 - 2
KulexiuForStudent/KulexiuForStudent/Module/Mine/Setting/Controller/UserSettingViewController.m

@@ -24,6 +24,7 @@
 #import <RSKImageCropper/RSKImageCropper.h>
 #import <KSSmallChoosePicker.h>
 #import <UIImageView+DisplayImage.h>
+#import "NSDate+Extension.h"
 
 @interface UserSettingViewController ()<RSKImageCropViewControllerDelegate>
 
@@ -273,10 +274,12 @@
     NSData *imgData = [UIImage turnsImaegDataByImage:image];
     NSString *fileName = @"image";
     [UPLOAD_MANAGER configWithfilePath:@"/user/"];
-    [UPLOAD_MANAGER uploadImage:imgData fileName:fileName successCallback:^(NSMutableArray * _Nonnull fileUrlArray) {
+    NSString *avatarName = [NSString stringWithFormat:@"%@.png", UserDefault(UIDKey)];
+    [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 birthday:nil];
-    } faliure:^(NSError * _Nullable error, NSString *descMessaeg) {
+    } faliure:^(NSError * _Nullable error, NSString * _Nullable descMessaeg) {
         if (![NSString isEmptyString:descMessaeg]) {
             [LOADING_MANAGER MBShowAUTOHidingInWindow:descMessaeg];
         }