更换腾讯cos上传

This commit is contained in:
启星
2025-10-24 10:52:40 +08:00
parent 22ba9e1070
commit 3a5cf56099
415 changed files with 47343 additions and 11864 deletions

View File

@@ -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;
}

View File

@@ -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(@"文件上传失败,请重新尝试");
}
}];
}