更换腾讯cos上传
This commit is contained in:
@@ -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(@"文件上传失败,请重新尝试");
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user