更换存储
This commit is contained in:
1
Podfile
1
Podfile
@@ -76,6 +76,7 @@ target 'YuMi' do
|
||||
pod 'WMZDropDownMenu'
|
||||
pod 'TABAnimated'
|
||||
pod 'YuMi',:path=>'yum'
|
||||
pod 'QCloudCOSXML'
|
||||
end
|
||||
|
||||
post_install do |installer|
|
||||
|
@@ -304,6 +304,7 @@
|
||||
239141C92AE1358F00322CA9 /* PIInputEntireServerScrollingView.m in Sources */ = {isa = PBXBuildFile; fileRef = 239141C82AE1358F00322CA9 /* PIInputEntireServerScrollingView.m */; };
|
||||
239141CC2AE267EF00322CA9 /* PIReceiveRedPacketSuccessView.m in Sources */ = {isa = PBXBuildFile; fileRef = 239141CB2AE267EF00322CA9 /* PIReceiveRedPacketSuccessView.m */; };
|
||||
23942E912A86424500D0ECC2 /* XPLoginAuthCodeVC.m in Sources */ = {isa = PBXBuildFile; fileRef = 23942E902A86424500D0ECC2 /* XPLoginAuthCodeVC.m */; };
|
||||
23959FE72BB15C930085A282 /* UploadFileModel.m in Sources */ = {isa = PBXBuildFile; fileRef = 23959FE62BB15C930085A282 /* UploadFileModel.m */; };
|
||||
2396FCE42B22BE5D0014021D /* pi_area_info.json in Resources */ = {isa = PBXBuildFile; fileRef = 2396FCE32B22BE5D0014021D /* pi_area_info.json */; };
|
||||
239BEEDB2AA1E058005CDA94 /* PIHoemCategoryTitleView.m in Sources */ = {isa = PBXBuildFile; fileRef = 239BEEDA2AA1E058005CDA94 /* PIHoemCategoryTitleView.m */; };
|
||||
23A03F2D2B4408CD0094227A /* pi_room_lucky_gift.svga in Resources */ = {isa = PBXBuildFile; fileRef = 23A03F2C2B4408CD0094227A /* pi_room_lucky_gift.svga */; };
|
||||
@@ -2080,6 +2081,8 @@
|
||||
239141CB2AE267EF00322CA9 /* PIReceiveRedPacketSuccessView.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = PIReceiveRedPacketSuccessView.m; sourceTree = "<group>"; };
|
||||
23942E8F2A86424500D0ECC2 /* XPLoginAuthCodeVC.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = XPLoginAuthCodeVC.h; sourceTree = "<group>"; };
|
||||
23942E902A86424500D0ECC2 /* XPLoginAuthCodeVC.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = XPLoginAuthCodeVC.m; sourceTree = "<group>"; };
|
||||
23959FE52BB15C930085A282 /* UploadFileModel.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = UploadFileModel.h; sourceTree = "<group>"; };
|
||||
23959FE62BB15C930085A282 /* UploadFileModel.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = UploadFileModel.m; sourceTree = "<group>"; };
|
||||
2396FCE32B22BE5D0014021D /* pi_area_info.json */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.json; path = pi_area_info.json; sourceTree = "<group>"; };
|
||||
239BEED92AA1E058005CDA94 /* PIHoemCategoryTitleView.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = PIHoemCategoryTitleView.h; sourceTree = "<group>"; };
|
||||
239BEEDA2AA1E058005CDA94 /* PIHoemCategoryTitleView.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = PIHoemCategoryTitleView.m; sourceTree = "<group>"; };
|
||||
@@ -6128,8 +6131,10 @@
|
||||
9B33E3C827D85379003B0E62 /* File */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
9B33E3C927D85379003B0E62 /* UploadFile.m */,
|
||||
9B33E3CA27D85379003B0E62 /* UploadFile.h */,
|
||||
9B33E3C927D85379003B0E62 /* UploadFile.m */,
|
||||
23959FE52BB15C930085A282 /* UploadFileModel.h */,
|
||||
23959FE62BB15C930085A282 /* UploadFileModel.m */,
|
||||
);
|
||||
path = File;
|
||||
sourceTree = "<group>";
|
||||
@@ -11300,6 +11305,7 @@
|
||||
189DD68426E1FDBB00AB55B1 /* XNDJTDDLoadingTool.m in Sources */,
|
||||
9B1B72AF280031F8003FACE9 /* XPAnchorPKSelectRoomView.m in Sources */,
|
||||
E818DD1C2A4896EE00F163F7 /* XPLoginAraeViewController.m in Sources */,
|
||||
23959FE72BB15C930085A282 /* UploadFileModel.m in Sources */,
|
||||
E8D4824A278D1F73003C1D08 /* XPAcrossRoomPKInviteView.m in Sources */,
|
||||
E85E7B432A4EB0D300B6D00A /* XPMineExchangeAuthorityHeadView.m in Sources */,
|
||||
23194DD02AD14BF000649F51 /* DDLog.m in Sources */,
|
||||
|
@@ -7,6 +7,7 @@
|
||||
|
||||
#import "AppDelegate+ThirdConfig.h"
|
||||
///Third
|
||||
#import <QCloudCOSXML/QCloudCOSXML.h>
|
||||
#import <NIMSDK/NIMSDK.h>
|
||||
#import <ShareSDK/ShareSDK.h>
|
||||
#import <UserNotifications/UNUserNotificationCenter.h>
|
||||
@@ -66,6 +67,9 @@ UIKIT_EXTERN NSString * adImageName;
|
||||
}];
|
||||
}
|
||||
|
||||
}
|
||||
-(void)initQCloud{
|
||||
|
||||
}
|
||||
/**
|
||||
崩溃收集 Bugly
|
||||
|
@@ -345,6 +345,8 @@ NS_ASSUME_NONNULL_BEGIN
|
||||
/// - roomUid: 房间id
|
||||
/// - type: 1=房间
|
||||
+(void)requestUnmaskingFromBlackRoomList:(HttpRequestHelperCompletion)completion objId:(NSString *)objId type:(NSString *)type ;
|
||||
///得到腾讯存储信息
|
||||
+ (void)getQCloudInfo:(HttpRequestHelperCompletion)completion;
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
|
@@ -139,7 +139,10 @@
|
||||
NSString * fang = [NSString stringFromBase64String:@"cWluaXUvdXBsb2FkL2dldFVwbG9hZFRva2Vu"];///qiniu/upload/getUploadToken
|
||||
[self makeRequest:fang method:HttpRequestHelperMethodGET completion:completion, __FUNCTION__, nil];
|
||||
}
|
||||
|
||||
///得到腾讯存储信息
|
||||
+ (void)getQCloudInfo:(HttpRequestHelperCompletion)completion{
|
||||
[self makeRequest:@"tencent/cos/getToken" method:HttpRequestHelperMethodGET completion:completion, __FUNCTION__, nil];
|
||||
}
|
||||
|
||||
/// 上传用户图像到服务器
|
||||
/// @param completion 完成
|
||||
|
@@ -10,7 +10,7 @@
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
@interface UploadFile : NSObject
|
||||
|
||||
+ (instancetype)share;
|
||||
/// 上传一个文件
|
||||
/// @param filePath 文件地址
|
||||
/// @param fileName 文件的名字
|
||||
|
@@ -4,12 +4,89 @@
|
||||
//
|
||||
// Created by GreenLand on 2022/2/23.
|
||||
//
|
||||
|
||||
#import <QCloudCOSXML/QCloudCOSXML.h>
|
||||
#import "UploadFile.h"
|
||||
#import <Qiniu/QiniuSDK.h>
|
||||
#import <AFNetworking.h>
|
||||
#import "Api+Mine.h"
|
||||
#import "UploadFileModel.h"
|
||||
static UploadFile* manager;
|
||||
|
||||
@interface UploadFile()<QCloudSignatureProvider>
|
||||
@property(nonatomic,strong) UploadFileModel *fileModel;
|
||||
@end
|
||||
|
||||
@implementation UploadFile
|
||||
|
||||
+ (instancetype)share {
|
||||
static dispatch_once_t onceToken;
|
||||
dispatch_once(&onceToken, ^{
|
||||
manager = [[UploadFile alloc] init];
|
||||
});
|
||||
return manager;
|
||||
}
|
||||
|
||||
-(void)initQCloud{
|
||||
[Api getQCloudInfo:^(BaseModel * _Nullable data, NSInteger code, NSString * _Nullable msg) {
|
||||
if (code == 200){
|
||||
UploadFileModel *fileModel = [UploadFileModel modelWithDictionary:data.data];
|
||||
self.fileModel = fileModel;
|
||||
QCloudServiceConfiguration* configuration = [QCloudServiceConfiguration new];
|
||||
QCloudCOSXMLEndPoint* endpoint = [[QCloudCOSXMLEndPoint alloc] init];
|
||||
|
||||
|
||||
|
||||
endpoint.regionName = fileModel.region;
|
||||
// 使用 HTTPS
|
||||
endpoint.useHTTPS = true;
|
||||
configuration.endpoint = endpoint;
|
||||
// 密钥提供者为自己
|
||||
configuration.signatureProvider = self;
|
||||
// 初始化 COS 服务示例
|
||||
[QCloudCOSXMLService registerDefaultCOSXMLWithConfiguration:configuration];
|
||||
[QCloudCOSTransferMangerService registerDefaultCOSTransferMangerWithConfiguration:
|
||||
configuration];
|
||||
|
||||
}
|
||||
}];
|
||||
}
|
||||
#pragma mark- QCloudSignatureProvider
|
||||
- (void) signatureWithFields:(QCloudSignatureFields*)fileds
|
||||
request:(QCloudBizHTTPRequest*)request
|
||||
urlRequest:(NSMutableURLRequest*)urlRequst
|
||||
compelete:(QCloudHTTPAuthentationContinueBlock)continueBlock
|
||||
{
|
||||
|
||||
QCloudCredential* credential = [QCloudCredential new];
|
||||
|
||||
|
||||
// 临时密钥 SecretId
|
||||
// sercret_id替换为用户的 SecretId,登录访问管理控制台查看密钥,https://console.cloud.tencent.com/cam/capi
|
||||
credential.secretID = self.fileModel.secretId;
|
||||
// 临时密钥 SecretKey
|
||||
// sercret_key替换为用户的 SecretKey,登录访问管理控制台查看密钥,https://console.cloud.tencent.com/cam/capi
|
||||
credential.secretKey = self.fileModel.secretKey;
|
||||
// 临时密钥 Token
|
||||
// 如果使用永久密钥不需要填入token,如果使用临时密钥需要填入,临时密钥生成和使用指引参见https://cloud.tencent.com/document/product/436/14048
|
||||
credential.token = self.fileModel.sessionToken;
|
||||
/** 强烈建议返回服务器时间作为签名的开始时间, 用来避免由于用户手机本地时间偏差过大导致的签名不正确(参数startTime和expiredTime单位为秒)
|
||||
*/
|
||||
credential.startDate = [NSDate dateWithTimeIntervalSince1970:self.fileModel.startTime]; // 单位是秒
|
||||
credential.expirationDate = [NSDate dateWithTimeIntervalSince1970:self.fileModel.startTime];// 单位是秒
|
||||
|
||||
|
||||
QCloudAuthentationV5Creator* creator = [[QCloudAuthentationV5Creator alloc]
|
||||
initWithCredential:credential];
|
||||
// 注意 这里不要对urlRequst 进行copy以及mutableCopy操作
|
||||
QCloudSignature *signature = [creator signatureForData:urlRequst];
|
||||
continueBlock(signature, nil);
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
//zoneAs0
|
||||
/// 上传一个文件
|
||||
/// @param filePath 文件地址
|
||||
|
23
YuMi/Tools/File/UploadFileModel.h
Normal file
23
YuMi/Tools/File/UploadFileModel.h
Normal file
@@ -0,0 +1,23 @@
|
||||
//
|
||||
// UploadFileModel.h
|
||||
// YuMi
|
||||
//
|
||||
// Created by duoban on 2024/3/25.
|
||||
//
|
||||
|
||||
#import <Foundation/Foundation.h>
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
@interface UploadFileModel : NSObject
|
||||
@property(nonatomic,copy) NSString *secretId;
|
||||
@property(nonatomic,copy) NSString *secretKey;
|
||||
@property(nonatomic,copy) NSString *sessionToken;
|
||||
@property(nonatomic,copy) NSString *bucket;
|
||||
@property(nonatomic,copy) NSString *region;
|
||||
@property(nonatomic,copy) NSString *customDomain;
|
||||
@property(nonatomic,assign) long startTime;
|
||||
@property(nonatomic,assign) long expireTime;
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
12
YuMi/Tools/File/UploadFileModel.m
Normal file
12
YuMi/Tools/File/UploadFileModel.m
Normal file
@@ -0,0 +1,12 @@
|
||||
//
|
||||
// UploadFileModel.m
|
||||
// YuMi
|
||||
//
|
||||
// Created by duoban on 2024/3/25.
|
||||
//
|
||||
|
||||
#import "UploadFileModel.h"
|
||||
|
||||
@implementation UploadFileModel
|
||||
|
||||
@end
|
Reference in New Issue
Block a user