更换腾讯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

@@ -171,23 +171,38 @@
}
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.headerBtn sd_setImageWithURL:[NSURL URLWithString:fileUrl] forState:(UIControlStateNormal)];
// weakSelf.isPhoto = YES;
// }else{
// showToastInView(QXText(@"文件上传失败,请重新尝试"), self.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) {
QXLOG(@"uploadstate --- %ld ---url---%@",state,names);
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.headerBtn sd_setImageWithURL:[NSURL URLWithString:fileUrl] forState:(UIControlStateNormal)];
weakSelf.isPhoto = YES;
if (state == QXCOSUploadImageSuccess) {
weakSelf.avartar = names.firstObject;
[weakSelf.headerBtn sd_setImageWithURL:[NSURL URLWithString:weakSelf.avartar] forState:(UIControlStateNormal)];
}else{
showToastInView(QXText(@"文件上传失败,请重新尝试"), self.view);
showToastInView(QXText(@"文件上传失败,请重新尝试"), weakSelf.view);
}
}];
}