更换腾讯cos上传
This commit is contained in:
@@ -214,20 +214,35 @@
|
||||
}
|
||||
NSMutableArray *files = [[NSMutableArray alloc] initWithObjects:fileData, nil];
|
||||
|
||||
NSString *fileBasePath = IMG_FILE_BASE_PATH;// 默认图片上传
|
||||
NSString *fileName = [NSString stringWithFormat:@"%@%@/%@.%@",fileBasePath,[[QXOSSManager sharedInstance] currentDate],[NSUUID UUID].UUIDString,contentType];
|
||||
NSMutableArray *fileNames = [[NSMutableArray alloc] initWithObjects:fileName, nil];
|
||||
// NSString *fileBasePath = IMG_FILE_BASE_PATH;// 默认图片上传
|
||||
// NSString *fileName = [NSString stringWithFormat:@"%@%@/%@.%@",fileBasePath,[[QXOSSManager sharedInstance] currentDate],[NSUUID UUID].UUIDString,contentType];
|
||||
// NSMutableArray *fileNames = [[NSMutableArray alloc] initWithObjects:fileName, nil];
|
||||
// __weak typeof(self)weakSelf = self;
|
||||
// showLoadingInView(self.view);
|
||||
// [[QXOSSManager sharedInstance] uploadFile:files withObjectKey:fileNames isAsync:YES complete:^(NSArray<NSString *> *names, UploadImageState state) {
|
||||
// dispatch_async(dispatch_get_main_queue(), ^{
|
||||
// hideLoadingInView(weakSelf.view);
|
||||
// });
|
||||
// if (state == UploadImageSuccess) {
|
||||
// NSString *fileName = [names lastObject];
|
||||
// NSString *fileUrl =[NSString stringWithFormat:@"https://%@.%@/%@",OSS_BUCKET_NAME,OSSEndPoint,fileName];
|
||||
// weakSelf.avartar = fileUrl;
|
||||
// [weakSelf.selectedBtn sd_setImageWithURL:[NSURL URLWithString:fileUrl] forState:(UIControlStateNormal)];
|
||||
// }else{
|
||||
// showToastInView(QXText(@"文件上传失败,请重新尝试"), weakSelf.view);
|
||||
// }
|
||||
// }];
|
||||
|
||||
__weak typeof(self)weakSelf = self;
|
||||
showLoadingInView(self.view);
|
||||
[[QXOSSManager sharedInstance] uploadFile:files withObjectKey:fileNames isAsync:YES complete:^(NSArray<NSString *> *names, UploadImageState state) {
|
||||
NSString *fileName = [NSString stringWithFormat:@"%@.%@",[[QXCOSUploadManager shareManager] currentDate],contentType];
|
||||
[[QXCOSUploadManager shareManager] uploadFile:files withObjectKey:@[fileName] isAsync:YES complete:^(NSArray<NSString *> * _Nonnull names, QXCOSUploadImageState state) {
|
||||
dispatch_async(dispatch_get_main_queue(), ^{
|
||||
hideLoadingInView(weakSelf.view);
|
||||
});
|
||||
if (state == UploadImageSuccess) {
|
||||
NSString *fileName = [names lastObject];
|
||||
NSString *fileUrl =[NSString stringWithFormat:@"https://%@.%@/%@",OSS_BUCKET_NAME,OSSEndPoint,fileName];
|
||||
weakSelf.avartar = fileUrl;
|
||||
[weakSelf.selectedBtn sd_setImageWithURL:[NSURL URLWithString:fileUrl] forState:(UIControlStateNormal)];
|
||||
if (state == QXCOSUploadImageSuccess) {
|
||||
weakSelf.avartar = names.firstObject;
|
||||
[weakSelf.selectedBtn sd_setImageWithURL:[NSURL URLWithString:weakSelf.avartar] forState:(UIControlStateNormal)];
|
||||
}else{
|
||||
showToastInView(QXText(@"文件上传失败,请重新尝试"), weakSelf.view);
|
||||
}
|
||||
|
||||
@@ -386,19 +386,38 @@
|
||||
[self presentViewController:imagePickerVc animated:YES completion:nil];
|
||||
}
|
||||
- (void)OSSUploadPhoto{
|
||||
// __weak typeof(self)weakSelf = self;
|
||||
// showLoadingInView(self.view);
|
||||
// [[QXOSSManager sharedInstance] activityUploadFile:self.uploadArray withObjectKey:self.keyArray isAsync:YES complete:^(NSArray<NSString *> *names, UploadImageState state) {
|
||||
// dispatch_async_and_wait(dispatch_get_main_queue(), ^{
|
||||
// [weakSelf.urlArray removeAllObjects];
|
||||
// hideLoadingInView(weakSelf.view);
|
||||
// if (state == UploadImageSuccess) {
|
||||
// showToast(QXText(@"上传成功"));
|
||||
// for (int i = 0; i < names.count; i++) {
|
||||
// NSString *name = names[i];
|
||||
// NSString *fileUrl =[NSString stringWithFormat:@"https://%@.%@/%@",OSS_BUCKET_NAME,OSSEndPoint,name];
|
||||
// [weakSelf.urlArray addObject:fileUrl];
|
||||
// }
|
||||
// [weakSelf uploadImages];
|
||||
// }else{
|
||||
// showToast(QXText(@"上传失败"));
|
||||
// }
|
||||
// });
|
||||
// }];
|
||||
__weak typeof(self)weakSelf = self;
|
||||
showLoadingInView(self.view);
|
||||
[[QXOSSManager sharedInstance] activityUploadFile:self.uploadArray withObjectKey:self.keyArray isAsync:YES complete:^(NSArray<NSString *> *names, UploadImageState state) {
|
||||
dispatch_async_and_wait(dispatch_get_main_queue(), ^{
|
||||
[weakSelf.urlArray removeAllObjects];
|
||||
[[QXCOSUploadManager shareManager] activityUploadFile:self.uploadArray withObjectKey:self.keyArray isAsync:YES complete:^(NSArray<NSString *> * _Nonnull names, QXCOSUploadImageState state) {
|
||||
dispatch_async(dispatch_get_main_queue(), ^{
|
||||
hideLoadingInView(weakSelf.view);
|
||||
if (state == UploadImageSuccess) {
|
||||
showToast(QXText(@"上传成功"));
|
||||
[weakSelf.urlArray removeAllObjects];
|
||||
if (state == QXCOSUploadImageSuccess) {
|
||||
for (int i = 0; i < names.count; i++) {
|
||||
NSString *name = names[i];
|
||||
NSString *fileUrl =[NSString stringWithFormat:@"https://%@.%@/%@",OSS_BUCKET_NAME,OSSEndPoint,name];
|
||||
[weakSelf.urlArray addObject:fileUrl];
|
||||
// NSString *fileUrl =[NSString stringWithFormat:@"https://%@.%@/%@",OSS_BUCKET_NAME,OSSEndPoint,name];
|
||||
[weakSelf.urlArray addObject:name];
|
||||
}
|
||||
showToast(QXText(@"上传成功"));
|
||||
[weakSelf uploadImages];
|
||||
}else{
|
||||
showToast(QXText(@"上传失败"));
|
||||
@@ -423,8 +442,10 @@
|
||||
}];
|
||||
}
|
||||
- (NSString *)imagePathWithKey:(NSString *)keyPath {
|
||||
NSString *fileBasePath = IMG_FILE_BASE_PATH;
|
||||
return [NSString stringWithFormat:@"%@%@/%@.%@",fileBasePath,[[QXOSSManager sharedInstance] currentDate],[NSUUID UUID].UUIDString,keyPath];
|
||||
// NSString *fileBasePath = IMG_FILE_BASE_PATH;
|
||||
// return [NSString stringWithFormat:@"%@%@/%@.%@",fileBasePath,[[QXOSSManager sharedInstance] currentDate],[NSUUID UUID].UUIDString,keyPath];
|
||||
NSString *fileName = [NSString stringWithFormat:@"%@.%@",[[QXCOSUploadManager shareManager] currentDate],keyPath];
|
||||
return fileName;
|
||||
}
|
||||
|
||||
-(NSMutableArray *)valueArray{
|
||||
|
||||
@@ -107,8 +107,11 @@
|
||||
[QXMineNetwork setUserDressIsCancel:isCancel udid:model.udid type:self.model.id successBlock:^(NSDictionary * _Nonnull dict) {
|
||||
if (weakSelf.model.id.intValue == 1) {
|
||||
[QXGlobal shareGlobal].loginModel.dress = model.play_image;
|
||||
[[QXGlobal shareGlobal] updateUserInfoWithMolde:[QXGlobal shareGlobal].loginModel];
|
||||
}
|
||||
if (weakSelf.model.id.intValue == 9) {
|
||||
[QXGlobal shareGlobal].loginModel.chat_bubble = model.base_image;
|
||||
}
|
||||
[[QXGlobal shareGlobal] updateUserInfoWithMolde:[QXGlobal shareGlobal].loginModel];
|
||||
showToast(@"设置成功");
|
||||
} failBlock:^(NSError * _Nonnull error, NSString * _Nonnull msg) {
|
||||
showToast(msg);
|
||||
|
||||
@@ -13,6 +13,7 @@
|
||||
#import "UIImage+QX.h"
|
||||
#import "QXTimer.h"
|
||||
#import "QXMineNetwork.h"
|
||||
#import "QXCOSUploadManager.h"
|
||||
|
||||
@interface QXCreateRoomViewController ()<UITextFieldDelegate>
|
||||
@property (nonatomic,strong) UILabel *roomCoverLabel;
|
||||
@@ -260,26 +261,33 @@
|
||||
QXLOG(@"资源加载错误");
|
||||
return;
|
||||
}
|
||||
if (fileData.length > 1024*1024 && [contentType isEqualToString:IMG_FILE_BASE_PATH]) {
|
||||
QXLOG(@"请不要上传超过1M的头像");
|
||||
return;
|
||||
}
|
||||
NSMutableArray *files = [[NSMutableArray alloc] initWithObjects:fileData, nil];
|
||||
|
||||
NSString *fileBasePath = IMG_FILE_BASE_PATH;// 默认图片上传
|
||||
NSString *fileName = [NSString stringWithFormat:@"%@%@/%@.%@",fileBasePath,[[QXOSSManager sharedInstance] currentDate],[NSUUID UUID].UUIDString,contentType];
|
||||
NSMutableArray *fileNames = [[NSMutableArray alloc] initWithObjects:fileName, nil];
|
||||
// NSString *fileBasePath = IMG_FILE_BASE_PATH;// 默认图片上传
|
||||
// NSString *fileName = [NSString stringWithFormat:@"%@%@/%@.%@",fileBasePath,[[QXOSSManager sharedInstance] currentDate],[NSUUID UUID].UUIDString,contentType];
|
||||
// NSMutableArray *fileNames = [[NSMutableArray alloc] initWithObjects:fileName, nil];
|
||||
// __weak typeof(self)weakSelf = self;
|
||||
// [QXProjectTools showLoadingInView:self.view];
|
||||
// [[QXOSSManager sharedInstance] uploadFile:files withObjectKey:fileNames isAsync:YES complete:^(NSArray<NSString *> *names, UploadImageState state) {
|
||||
// dispatch_async(dispatch_get_main_queue(), ^{
|
||||
// [QXProjectTools hideLoadingInView:self.view];
|
||||
// });
|
||||
// if (state == UploadImageSuccess) {
|
||||
// NSString *fileName = [names lastObject];
|
||||
// NSString *fileUrl =[NSString stringWithFormat:@"https://%@.%@/%@",OSS_BUCKET_NAME,OSSEndPoint,fileName];
|
||||
// weakSelf.roomCoverUrl = fileUrl;
|
||||
// [weakSelf.roomImageView sd_setImageWithURL:[NSURL URLWithString:fileUrl] placeholderImage:[UIImage imageNamed:@"mine_room_cover_add"]];
|
||||
// }else{
|
||||
// QXLOG(@"文件上传失败,请重新尝试");
|
||||
// }
|
||||
// }];
|
||||
__weak typeof(self)weakSelf = self;
|
||||
[QXProjectTools showLoadingInView:self.view];
|
||||
[[QXOSSManager sharedInstance] uploadFile:files withObjectKey:fileNames isAsync:YES complete:^(NSArray<NSString *> *names, UploadImageState state) {
|
||||
dispatch_async(dispatch_get_main_queue(), ^{
|
||||
[QXProjectTools hideLoadingInView:self.view];
|
||||
});
|
||||
if (state == UploadImageSuccess) {
|
||||
NSString *fileName = [names lastObject];
|
||||
NSString *fileUrl =[NSString stringWithFormat:@"https://%@.%@/%@",OSS_BUCKET_NAME,OSSEndPoint,fileName];
|
||||
weakSelf.roomCoverUrl = fileUrl;
|
||||
[weakSelf.roomImageView sd_setImageWithURL:[NSURL URLWithString:fileUrl] placeholderImage:[UIImage imageNamed:@"mine_room_cover_add"]];
|
||||
NSString *fileName = [NSString stringWithFormat:@"%@.%@",[[QXCOSUploadManager shareManager] currentDate],contentType];
|
||||
[[QXCOSUploadManager shareManager] uploadFile:files withObjectKey:@[fileName] isAsync:YES complete:^(NSArray<NSString *> * _Nonnull names, QXCOSUploadImageState state) {
|
||||
QXLOG(@"uploadstate --- %ld ---url---%@",state,names);
|
||||
if (state == QXCOSUploadImageSuccess) {
|
||||
weakSelf.roomCoverUrl = names.firstObject;
|
||||
[weakSelf.roomImageView sd_setImageWithURL:[NSURL URLWithString:weakSelf.roomCoverUrl] placeholderImage:[UIImage imageNamed:@"mine_room_cover_add"]];
|
||||
}else{
|
||||
QXLOG(@"文件上传失败,请重新尝试");
|
||||
}
|
||||
|
||||
@@ -33,6 +33,8 @@ NS_ASSUME_NONNULL_BEGIN
|
||||
@property (nonatomic,strong)NSString *charm_level;
|
||||
/// 装扮
|
||||
@property (nonatomic,strong)NSString *dress;
|
||||
/// 聊天气泡
|
||||
@property (nonatomic,strong)NSString *chat_bubble;
|
||||
/// 是否已实名 1 已实名 0 未实名
|
||||
@property (nonatomic,strong)NSString *auth;
|
||||
/// 是否使用靓号 0未使用 1 已使用
|
||||
@@ -64,6 +66,8 @@ NS_ASSUME_NONNULL_BEGIN
|
||||
@property (nonatomic,strong)NSString *sex;
|
||||
/// 装扮
|
||||
@property (nonatomic,strong)NSString *dress;
|
||||
/// 聊天气泡
|
||||
@property (nonatomic,strong)NSString *chat_bubble;
|
||||
/// ip
|
||||
@property (nonatomic,strong)NSString *loginip;
|
||||
/// 昵称
|
||||
|
||||
@@ -24,6 +24,7 @@
|
||||
#import "QXRoomUserCharmModel.h"
|
||||
#import "QXRoomHourRankModel.h"
|
||||
#import "QXRedPacketModel.h"
|
||||
#import "QXEmojiTypeModel.h"
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
@@ -1135,6 +1136,25 @@ NS_ASSUME_NONNULL_BEGIN
|
||||
room_id:(NSString*)room_id
|
||||
successBlock:(void (^)(NSDictionary* dict))successBlock
|
||||
failBlock:(void (^)(NSError * error, NSString * msg))failBlock;
|
||||
|
||||
|
||||
|
||||
/**
|
||||
表情类型列表
|
||||
*/
|
||||
+(void)roomEmojiTypeListSuccessBlock:(void (^)(NSArray <QXEmojiTypeModel*>* list))successBlock
|
||||
failBlock:(void (^)(NSError * error, NSString * msg))failBlock;
|
||||
|
||||
|
||||
|
||||
/**
|
||||
表情列表
|
||||
*/
|
||||
+(void)roomEmojiListWithTypeId:(NSString*)type_id
|
||||
pid:(NSString*)pid
|
||||
successBlock:(void (^)(NSArray <QXEmojiModel*>* list))successBlock
|
||||
failBlock:(void (^)(NSError * error, NSString * msg))failBlock;
|
||||
|
||||
@end
|
||||
|
||||
|
||||
|
||||
@@ -17,6 +17,7 @@
|
||||
[QXGlobal shareGlobal].loginModel.icon = userModel.icon;
|
||||
[QXGlobal shareGlobal].loginModel.dress = userModel.dress;
|
||||
[QXGlobal shareGlobal].loginModel.auth = userModel.auth.intValue;
|
||||
[QXGlobal shareGlobal].loginModel.chat_bubble = userModel.chat_bubble;
|
||||
[[QXGlobal shareGlobal] updateUserInfoWithMolde:[QXGlobal shareGlobal].loginModel];
|
||||
[[NSUserDefaults standardUserDefaults] setInteger:userModel.is_can_chat forKey:kIsCanChat];
|
||||
[[NSUserDefaults standardUserDefaults] setObject:userModel.can_chat_money forKey:kIsCanChatMoney];
|
||||
@@ -2209,4 +2210,42 @@
|
||||
failBlock(error,msg);
|
||||
}];
|
||||
}
|
||||
|
||||
/**
|
||||
表情类型列表
|
||||
*/
|
||||
+(void)roomEmojiTypeListSuccessBlock:(void (^)(NSArray <QXEmojiTypeModel*>* list))successBlock
|
||||
failBlock:(void (^)(NSError * error, NSString * msg))failBlock{
|
||||
[[QXRequset shareInstance] getWithUrl:QXRoomEmoji parameters:@{} needCache:NO success:^(id responseObject) {
|
||||
if (successBlock) {
|
||||
NSArray*list = [NSArray yy_modelArrayWithClass:[QXEmojiTypeModel class] json:responseObject[@"data"]];
|
||||
successBlock(list);
|
||||
}
|
||||
} fail:^(NSError *error, NSString *msg, NSURLSessionDataTask *task) {
|
||||
failBlock(error,msg);
|
||||
}];
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
表情列表
|
||||
*/
|
||||
+(void)roomEmojiListWithTypeId:(NSString*)type_id
|
||||
pid:(NSString*)pid
|
||||
successBlock:(void (^)(NSArray <QXEmojiModel*>* list))successBlock
|
||||
failBlock:(void (^)(NSError * error, NSString * msg))failBlock{
|
||||
NSDictionary *parameters =@{
|
||||
@"type_id":type_id?type_id:@"",
|
||||
// @"pid":pid?pid:@""
|
||||
};
|
||||
[[QXRequset shareInstance] getWithUrl:QXRoomEmojiList parameters:parameters needCache:NO success:^(id responseObject) {
|
||||
if (successBlock) {
|
||||
NSArray*list = [NSArray yy_modelArrayWithClass:[QXEmojiModel class] json:responseObject[@"data"]];
|
||||
successBlock(list);
|
||||
}
|
||||
} fail:^(NSError *error, NSString *msg, NSURLSessionDataTask *task) {
|
||||
failBlock(error,msg);
|
||||
}];
|
||||
}
|
||||
@end
|
||||
|
||||
@@ -206,9 +206,53 @@
|
||||
[self.viewController presentViewController:imagePickerVc animated:YES completion:nil];
|
||||
}
|
||||
- (void)OSSUploadPhoto{
|
||||
// __weak typeof(self)weakSelf = self;
|
||||
// showLoadingInView(self.viewController.view);
|
||||
// [[QXOSSManager sharedInstance] activityUploadFile:self.dataArray withObjectKey:self.keyArray isAsync:YES complete:^(NSArray<NSString *> *names, UploadImageState state) {
|
||||
// dispatch_async_and_wait(dispatch_get_main_queue(), ^{
|
||||
// hideLoadingInView(weakSelf.viewController.view);
|
||||
// if (state == UploadImageSuccess) {
|
||||
// showToast(QXText(@"上传成功"));
|
||||
// if (self.imgs == nil) {
|
||||
// [weakSelf.urlArray removeAllObjects];
|
||||
// if (names.count < self.maxCount) {
|
||||
// for (NSString*fileName in names) {
|
||||
// NSString *fileUrl =[NSString stringWithFormat:@"https://%@.%@/%@",OSS_BUCKET_NAME,OSSEndPoint,fileName];
|
||||
// [weakSelf.urlArray addObject:fileUrl];
|
||||
// }
|
||||
// [weakSelf.urlArray addObject:@"mine_room_cover_add"];
|
||||
// }else if (names.count == self.maxCount){
|
||||
// for (NSString*fileName in names) {
|
||||
// NSString *fileUrl =[NSString stringWithFormat:@"https://%@.%@/%@",OSS_BUCKET_NAME,OSSEndPoint,fileName];
|
||||
// [weakSelf.urlArray addObject:fileUrl];
|
||||
// }
|
||||
// }else{
|
||||
// for (int i = 0; i < self.maxCount; i++) {
|
||||
// NSString *name = names[i];
|
||||
// NSString *fileUrl =[NSString stringWithFormat:@"https://%@.%@/%@",OSS_BUCKET_NAME,OSSEndPoint,name];
|
||||
// [weakSelf.urlArray addObject:fileUrl];
|
||||
// }
|
||||
// }
|
||||
// [weakSelf uploadImgs];
|
||||
// }else{
|
||||
// NSMutableArray *arr = [NSMutableArray array];
|
||||
// for (NSString*fileName in names) {
|
||||
// NSString *fileUrl =[NSString stringWithFormat:@"https://%@.%@/%@",OSS_BUCKET_NAME,OSSEndPoint,fileName];
|
||||
// [weakSelf.urlArray insertObject:fileUrl atIndex:0];
|
||||
// [arr addObject:fileUrl];
|
||||
// }
|
||||
// [weakSelf uploadImgs:arr];
|
||||
// }
|
||||
//
|
||||
// }else{
|
||||
// showToast(QXText(@"上传失败"));
|
||||
// }
|
||||
// });
|
||||
// }];
|
||||
|
||||
__weak typeof(self)weakSelf = self;
|
||||
showLoadingInView(self.viewController.view);
|
||||
[[QXOSSManager sharedInstance] activityUploadFile:self.dataArray withObjectKey:self.keyArray isAsync:YES complete:^(NSArray<NSString *> *names, UploadImageState state) {
|
||||
[[QXCOSUploadManager shareManager] activityUploadFile:self.dataArray withObjectKey:self.keyArray isAsync:YES complete:^(NSArray<NSString *> * _Nonnull names, QXCOSUploadImageState state) {
|
||||
dispatch_async_and_wait(dispatch_get_main_queue(), ^{
|
||||
hideLoadingInView(weakSelf.viewController.view);
|
||||
if (state == UploadImageSuccess) {
|
||||
@@ -217,29 +261,29 @@
|
||||
[weakSelf.urlArray removeAllObjects];
|
||||
if (names.count < self.maxCount) {
|
||||
for (NSString*fileName in names) {
|
||||
NSString *fileUrl =[NSString stringWithFormat:@"https://%@.%@/%@",OSS_BUCKET_NAME,OSSEndPoint,fileName];
|
||||
[weakSelf.urlArray addObject:fileUrl];
|
||||
// NSString *fileUrl =[NSString stringWithFormat:@"https://%@.%@/%@",OSS_BUCKET_NAME,OSSEndPoint,fileName];
|
||||
[weakSelf.urlArray addObject:fileName];
|
||||
}
|
||||
[weakSelf.urlArray addObject:@"mine_room_cover_add"];
|
||||
}else if (names.count == self.maxCount){
|
||||
for (NSString*fileName in names) {
|
||||
NSString *fileUrl =[NSString stringWithFormat:@"https://%@.%@/%@",OSS_BUCKET_NAME,OSSEndPoint,fileName];
|
||||
[weakSelf.urlArray addObject:fileUrl];
|
||||
// NSString *fileUrl =[NSString stringWithFormat:@"https://%@.%@/%@",OSS_BUCKET_NAME,OSSEndPoint,fileName];
|
||||
[weakSelf.urlArray addObject:fileName];
|
||||
}
|
||||
}else{
|
||||
for (int i = 0; i < self.maxCount; i++) {
|
||||
NSString *name = names[i];
|
||||
NSString *fileUrl =[NSString stringWithFormat:@"https://%@.%@/%@",OSS_BUCKET_NAME,OSSEndPoint,name];
|
||||
[weakSelf.urlArray addObject:fileUrl];
|
||||
// NSString *fileUrl =[NSString stringWithFormat:@"https://%@.%@/%@",OSS_BUCKET_NAME,OSSEndPoint,name];
|
||||
[weakSelf.urlArray addObject:name];
|
||||
}
|
||||
}
|
||||
[weakSelf uploadImgs];
|
||||
}else{
|
||||
NSMutableArray *arr = [NSMutableArray array];
|
||||
for (NSString*fileName in names) {
|
||||
NSString *fileUrl =[NSString stringWithFormat:@"https://%@.%@/%@",OSS_BUCKET_NAME,OSSEndPoint,fileName];
|
||||
[weakSelf.urlArray insertObject:fileUrl atIndex:0];
|
||||
[arr addObject:fileUrl];
|
||||
// NSString *fileUrl =[NSString stringWithFormat:@"https://%@.%@/%@",OSS_BUCKET_NAME,OSSEndPoint,fileName];
|
||||
[weakSelf.urlArray insertObject:fileName atIndex:0];
|
||||
[arr addObject:fileName];
|
||||
}
|
||||
[weakSelf uploadImgs:arr];
|
||||
}
|
||||
@@ -251,8 +295,10 @@
|
||||
}];
|
||||
}
|
||||
- (NSString *)imagePathWithKey:(NSString *)keyPath {
|
||||
NSString *fileBasePath = IMG_FILE_BASE_PATH;
|
||||
return [NSString stringWithFormat:@"%@%@/%@.%@",fileBasePath,[[QXOSSManager sharedInstance] currentDate],[NSUUID UUID].UUIDString,keyPath];
|
||||
// NSString *fileBasePath = IMG_FILE_BASE_PATH;
|
||||
// return [NSString stringWithFormat:@"%@%@/%@.%@",fileBasePath,[[QXOSSManager sharedInstance] currentDate],[NSUUID UUID].UUIDString,keyPath];
|
||||
NSString *fileName = [NSString stringWithFormat:@"%@.%@",[[QXCOSUploadManager shareManager] currentDate],keyPath];
|
||||
return fileName;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -122,22 +122,33 @@
|
||||
}
|
||||
NSMutableArray *files = [[NSMutableArray alloc] initWithObjects:fileData, nil];
|
||||
|
||||
NSString *fileBasePath = IMG_FILE_BASE_PATH;// 默认图片上传
|
||||
NSString *fileName = [NSString stringWithFormat:@"%@%@/%@.%@",fileBasePath,[[QXOSSManager sharedInstance] currentDate],[NSUUID UUID].UUIDString,contentType];
|
||||
NSMutableArray *fileNames = [[NSMutableArray alloc] initWithObjects:fileName, nil];
|
||||
// NSString *fileBasePath = IMG_FILE_BASE_PATH;// 默认图片上传
|
||||
// NSString *fileName = [NSString stringWithFormat:@"%@%@/%@.%@",fileBasePath,[[QXOSSManager sharedInstance] currentDate],[NSUUID UUID].UUIDString,contentType];
|
||||
// NSMutableArray *fileNames = [[NSMutableArray alloc] initWithObjects:fileName, nil];
|
||||
// __weak typeof(self)weakSelf = self;
|
||||
// showLoadingInView(self.viewController.view);
|
||||
// [[QXOSSManager sharedInstance] uploadFile:files withObjectKey:fileNames isAsync:YES complete:^(NSArray<NSString *> *names, UploadImageState state) {
|
||||
// dispatch_async(dispatch_get_main_queue(), ^{
|
||||
// hideLoadingInView(weakSelf.viewController.view);
|
||||
// });
|
||||
// if (state == UploadImageSuccess) {
|
||||
// NSString *fileName = [names lastObject];
|
||||
// NSString *fileUrl =[NSString stringWithFormat:@"https://%@.%@/%@",OSS_BUCKET_NAME,OSSEndPoint,fileName];
|
||||
// weakSelf.avartar = fileUrl;
|
||||
// [weakSelf chamgeAvatar];
|
||||
// }else{
|
||||
// showToastInView(QXText(@"文件上传失败,请重新尝试"), weakSelf.viewController.view);
|
||||
// }
|
||||
// }];
|
||||
__weak typeof(self)weakSelf = self;
|
||||
showLoadingInView(self.viewController.view);
|
||||
[[QXOSSManager sharedInstance] uploadFile:files withObjectKey:fileNames isAsync:YES complete:^(NSArray<NSString *> *names, UploadImageState state) {
|
||||
dispatch_async(dispatch_get_main_queue(), ^{
|
||||
hideLoadingInView(weakSelf.viewController.view);
|
||||
});
|
||||
if (state == UploadImageSuccess) {
|
||||
NSString *fileName = [names lastObject];
|
||||
NSString *fileUrl =[NSString stringWithFormat:@"https://%@.%@/%@",OSS_BUCKET_NAME,OSSEndPoint,fileName];
|
||||
weakSelf.avartar = fileUrl;
|
||||
NSString *fileName = [NSString stringWithFormat:@"%@.%@",[[QXCOSUploadManager shareManager] currentDate],contentType];
|
||||
[[QXCOSUploadManager shareManager] uploadFile:files withObjectKey:@[fileName] isAsync:YES complete:^(NSArray<NSString *> * _Nonnull names, QXCOSUploadImageState state) {
|
||||
QXLOG(@"uploadstate --- %ld ---url---%@",state,names);
|
||||
if (state == QXCOSUploadImageSuccess) {
|
||||
weakSelf.avartar = names.firstObject;
|
||||
[weakSelf chamgeAvatar];
|
||||
}else{
|
||||
showToastInView(QXText(@"文件上传失败,请重新尝试"), weakSelf.viewController.view);
|
||||
QXLOG(@"文件上传失败,请重新尝试");
|
||||
}
|
||||
}];
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user