|
@@ -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) {
|