Skip to content

Commit 56ff768

Browse files
author
erichmzhang
committed
COS XML 5.3.0 Release
1 parent 11a8567 commit 56ff768

File tree

93 files changed

+2149
-300
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

93 files changed

+2149
-300
lines changed

CHANGELOG.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,15 @@
1+
# 5.3.0
2+
- 增加了生成预签名 URL 的接口。
3+
- 增加列出指定前缀 Object 所有版本的接口。
4+
- 增加从 CAS 归档恢复的接口。
5+
- Get, Put, Delete, Head Object等相关接口支持多版本。
6+
- 上传过程中增加了 MD5 校验。
7+
- 下载过程中可以开启 MD5 校验。
8+
- 针对弱网络情况进行优化,大幅度提高弱网络情况下上传成功率。
9+
- 修复分块 Copy 大文件的问题。
10+
- 签名计算时支持自定义开始和结束时间。
11+
12+
113
# 5.2.0
214
- 增加了精简版的SDK,只支持上传下载功能。
315
- BucketName概念统一。

QCloudCOSXML.podspec

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
Pod::Spec.new do |s|
22
s.name = "QCloudCOSXML"
3-
s.version = "5.2.0"
3+
s.version = "5.3.0"
44
s.summary = "QCloudCOSXML 腾讯云iOS-SDK组件"
55

66
s.homepage = "https://cloud.tencent.com/"
@@ -9,10 +9,10 @@ Pod::Spec.new do |s|
99
s.source = { :git => "https://github.com/tencentyun/qcloud-sdk-ios.git", :tag => s.version.to_s }
1010
s.ios.deployment_target = '8.0'
1111
s.source_files = 'QCloudCOSXML/Classes/**/*'
12-
s.dependency "QCloudCore",'5.2.0'
12+
s.dependency "QCloudCore",'5.3.0'
1313

1414
s.subspec 'Transfer' do |sbt|
1515
sbt.source_files = 'QCloudCOSXML/Classes/Transfer/*','QCloudCOSXML/Classes/Base/*'
16-
sbt.dependency "QCloudCore",'5.2.0'
16+
sbt.dependency "QCloudCore",'5.3.0'
1717
end
1818
end

QCloudCOSXML/Classes/Base/QCloudCOSXMLService.h

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
#import <Foundation/Foundation.h>
3030
#import <QCloudCore/QCloudService.h>
3131

32-
32+
@class QCloudGetPresignedURLRequest;
3333
@interface QCloudCOSXMLService : QCloudService
3434

3535
#pragma hidden super selectors
@@ -43,4 +43,21 @@
4343
+ (QCloudCOSXMLService*) registerCOSXMLWithConfiguration:(QCloudServiceConfiguration*)configuration withKey:(NSString*)key;
4444
+ (void) removeCOSXMLWithKey:(NSString*)key;
4545

46+
/**
47+
根据Bukcet, Object来生成可以直接访问的URL。如果您的Bucket是私有读的话,那么访问的时候需要带上签名,反之则不需要。
48+
49+
50+
需要注意的是,如果通过该接口来生成带签名的URL的话,因为签名可能是在服务器生成的,该方法是同步方法,可能因为网络请求阻塞,建议不要在主线程里调用。
51+
52+
此外, 传入的Object需要是URLEncode后的结果。
53+
54+
@param bucket 存储桶
55+
@param object 存储对象, 请传入URL Encode后的结果
56+
@param withAuthorization 是否需要签名,如果是私有读的Bucket,那么该URL需要带上签名才能访问
57+
@return object URL
58+
*/
59+
- (NSString*)getURLWithBucket:(NSString*)bucket object:(NSString*)object withAuthorization:(BOOL)withAuthorization;
60+
61+
- (void) getPresignedURL:(QCloudGetPresignedURLRequest*)request;
62+
4663
@end

QCloudCOSXML/Classes/Base/QCloudCOSXMLService.m

Lines changed: 48 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
#import "QCloudCOSXMLService+Private.h"
3030
#import "QCloudThreadSafeMutableDictionary.h"
3131
#import "QCLoudError.h"
32-
32+
#import "QCloudGetPresignedURLRequest.h"
3333

3434
QCloudThreadSafeMutableDictionary* QCloudCOSXMLServiceCache()
3535
{
@@ -82,6 +82,53 @@ + (QCloudCOSXMLService*) registerCOSXMLWithConfiguration:(QCloudServiceConfigura
8282
[QCloudCOSXMLServiceCache() setObject:cosxmlService forKey:key];
8383
return cosxmlService;
8484
}
85+
- (NSString*)getURLWithBucket:(NSString *)bucket object:(NSString *)object withAuthorization:(BOOL)withAuthorization {
86+
NSParameterAssert(bucket);
87+
NSParameterAssert(object);
88+
__block NSMutableString* resultURL = [[NSMutableString alloc] init];
89+
NSString* bucketURL = [[self.configuration.endpoint serverURLWithBucket:bucket appID:self.configuration.appID] absoluteString];
90+
[resultURL appendString:bucketURL];
91+
[resultURL appendFormat:@"/%@",object];
92+
if (withAuthorization) {
93+
dispatch_semaphore_t semaphore = dispatch_semaphore_create(0);
94+
NSMutableURLRequest* fakeURLRequest = [[NSMutableURLRequest alloc] init];
95+
[fakeURLRequest setHTTPMethod:@"GET"];
96+
[fakeURLRequest setURL:[NSURL URLWithString:resultURL]];
97+
[self.configuration.signatureProvider signatureWithFields:nil request:nil urlRequest:fakeURLRequest compelete:^(QCloudSignature *signature, NSError *error) {
98+
NSString* sign = signature.signature;
99+
sign = QCloudURLEncodeUTF8(sign);
100+
[resultURL appendFormat:@"?sign=%@",sign];
101+
dispatch_semaphore_signal(semaphore);
102+
}];
103+
dispatch_semaphore_wait(semaphore, dispatch_time(DISPATCH_TIME_NOW, 5*NSEC_PER_SEC));
104+
}
105+
return [resultURL copy];
106+
}
107+
108+
- (void) getPresignedURL:(QCloudGetPresignedURLRequest*)request {
85109

110+
request.runOnService = self;
111+
NSError* error;
112+
NSURLRequest* urlRequest = [request buildURLRequest:&error];
113+
if (nil != error) {
114+
[request onError:error];
115+
return ;
116+
}
117+
__block NSString* requestURLString = urlRequest.URL.absoluteString;
118+
[self loadCOSXMLAuthorizationForBiz:request urlRequest:urlRequest compelete:^(QCloudSignature *signature, NSError *error) {
119+
NSString* authorizatioinString = signature.signature;
120+
if ([requestURLString hasSuffix:@"&"] || [requestURLString hasSuffix:@"?"]) {
121+
requestURLString = [requestURLString stringByAppendingString:authorizatioinString];
122+
} else {
123+
requestURLString = [requestURLString stringByAppendingFormat:@"?%@",authorizatioinString];
124+
}
125+
QCloudGetPresignedURLResult* result = [[QCloudGetPresignedURLResult alloc] init];
126+
result.presienedURL = requestURLString;
127+
if (request.finishBlock) {
128+
request.finishBlock(result, nil);
129+
}
130+
}];
131+
132+
}
86133

87134
@end

QCloudCOSXML/Classes/Base/QCloudCOSXMLVersion.m

Lines changed: 0 additions & 16 deletions
This file was deleted.
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
//
2+
// QCloudRequestData+COSXMLVersion.h
3+
// QCloudCOSXML
4+
//
5+
// Created by erichmzhang(张恒铭) on 22/01/2018.
6+
//
7+
8+
#import <QCloudCore/QCloudCore.h>
9+
10+
@interface QCloudRequestData (COSXMLVersion)
11+
12+
@end
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
//
2+
// QCloudRequestData+COSXMLVersion.m
3+
// QCloudCOSXML
4+
//
5+
// Created by erichmzhang(张恒铭) on 22/01/2018.
6+
//
7+
8+
#import "QCloudRequestData+COSXMLVersion.h"
9+
10+
@implementation QCloudRequestData (COSXMLVersion)
11+
12+
@end
Lines changed: 21 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,10 @@
11
//
2+
// CASJobParameters.h
3+
// CASJobParameters
4+
//
5+
// Created by tencent
6+
// Copyright (c) 2015年 tencent. All rights reserved.
7+
//
28
// ██████╗ ██████╗██╗ ██████╗ ██╗ ██╗██████╗ ████████╗███████╗██████╗ ███╗ ███╗██╗███╗ ██╗ █████╗ ██╗ ██╗ █████╗ ██████╗
39
// ██╔═══██╗██╔════╝██║ ██╔═══██╗██║ ██║██╔══██╗ ╚══██╔══╝██╔════╝██╔══██╗████╗ ████║██║████╗ ██║██╔══██╗██║ ██║ ██╔══██╗██╔══██╗
410
// ██║ ██║██║ ██║ ██║ ██║██║ ██║██║ ██║ ██║ █████╗ ██████╔╝██╔████╔██║██║██╔██╗ ██║███████║██║ ██║ ███████║██████╔╝
@@ -10,25 +16,24 @@
1016
// _ __ _ _
1117
// (_) / _| | | | |
1218
// ___ ___ _ ____ ___ ___ ___ | |_ ___ _ __ __| | _____ _____| | ___ _ __ ___ _ __ ___
13-
// / __|/ _ \\ '__\\ \\ / / |/ __/ _ \\ | _/ _ \\| '__| / _` |/ _ \\ \\ / / _ \\ |/ _ \\| '_ \\ / _ \\ '__/ __|
14-
// \\__ \\ __/ | \\ V /| | (_| __/ | || (_) | | | (_| | __/\\ V / __/ | (_) | |_) | __/ | \\__
15-
// |___/\\___|_| \\_/ |_|\\___\\___| |_| \\___/|_| \\__,_|\\___| \\_/ \\___|_|\\___/| .__/ \\___|_| |___/
19+
// / __|/ _ \ '__\ \ / / |/ __/ _ \ | _/ _ \| '__| / _` |/ _ \ \ / / _ \ |/ _ \| '_ \ / _ \ '__/ __|
20+
// \__ \ __/ | \ V /| | (_| __/ | || (_) | | | (_| | __/\ V / __/ | (_) | |_) | __/ | \__
21+
// |___/\___|_| \_/ |_|\___\___| |_| \___/|_| \__,_|\___| \_/ \___|_|\___/| .__/ \___|_| |___/
1622
// ______ ______ ______ ______ ______ ______ ______ ______ | |
1723
// |______|______|______|______|______|______|______|______| |_|
1824
//
19-
#import <Foundation/Foundation.h>
20-
#import <QCloudCore/QCloudCoreVersion.h>
2125

22-
#ifndef QCloudCOSXMLModuleVersion_h
23-
#define QCloudCOSXMLModuleVersion_h
24-
#define QCloudCOSXMLModuleVersionNumber 1001
2526

26-
//dependency
27-
//#if QCloudCoreModuleVersionNumber != 1001
28-
// #error "库QCloudCOSXML依赖QCloudCore最小版本号为0.1.1,当前引入的QCloudCore版本号过低,请及时升级后使用"
29-
//#endif
30-
//
31-
FOUNDATION_EXTERN NSString * const QCloudCOSXMLModuleVersion;
32-
FOUNDATION_EXTERN NSString * const QCloudCOSXMLModuleName;
3327

34-
#endif
28+
#import <Foundation/Foundation.h>
29+
#import <QCloudCore/QCloudCore.h>
30+
#import "QCloudCASTierEnum.h"
31+
32+
NS_ASSUME_NONNULL_BEGIN
33+
@interface CASJobParameters : NSObject
34+
/**
35+
复原的过程类型配置信息
36+
*/
37+
@property (assign, nonatomic) QCloudCASTier tier;
38+
@end
39+
NS_ASSUME_NONNULL_END
Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
//
2+
// CASJobParameters.m
3+
// CASJobParameters
4+
//
5+
// Created by tencent
6+
// Copyright (c) 2015年 tencent. All rights reserved.
7+
//
8+
// ██████╗ ██████╗██╗ ██████╗ ██╗ ██╗██████╗ ████████╗███████╗██████╗ ███╗ ███╗██╗███╗ ██╗ █████╗ ██╗ ██╗ █████╗ ██████╗
9+
// ██╔═══██╗██╔════╝██║ ██╔═══██╗██║ ██║██╔══██╗ ╚══██╔══╝██╔════╝██╔══██╗████╗ ████║██║████╗ ██║██╔══██╗██║ ██║ ██╔══██╗██╔══██╗
10+
// ██║ ██║██║ ██║ ██║ ██║██║ ██║██║ ██║ ██║ █████╗ ██████╔╝██╔████╔██║██║██╔██╗ ██║███████║██║ ██║ ███████║██████╔╝
11+
// ██║▄▄ ██║██║ ██║ ██║ ██║██║ ██║██║ ██║ ██║ ██╔══╝ ██╔══██╗██║╚██╔╝██║██║██║╚██╗██║██╔══██║██║ ██║ ██╔══██║██╔══██╗
12+
// ╚██████╔╝╚██████╗███████╗╚██████╔╝╚██████╔╝██████╔╝ ██║ ███████╗██║ ██║██║ ╚═╝ ██║██║██║ ╚████║██║ ██║███████╗ ███████╗██║ ██║██████╔╝
13+
// ╚══▀▀═╝ ╚═════╝╚══════╝ ╚═════╝ ╚═════╝ ╚═════╝ ╚═╝ ╚══════╝╚═╝ ╚═╝╚═╝ ╚═╝╚═╝╚═╝ ╚═══╝╚═╝ ╚═╝╚══════╝ ╚══════╝╚═╝ ╚═╝╚═════╝
14+
//
15+
//
16+
// _ __ _ _
17+
// (_) / _| | | | |
18+
// ___ ___ _ ____ ___ ___ ___ | |_ ___ _ __ __| | _____ _____| | ___ _ __ ___ _ __ ___
19+
// / __|/ _ \ '__\ \ / / |/ __/ _ \ | _/ _ \| '__| / _` |/ _ \ \ / / _ \ |/ _ \| '_ \ / _ \ '__/ __|
20+
// \__ \ __/ | \ V /| | (_| __/ | || (_) | | | (_| | __/\ V / __/ | (_) | |_) | __/ | \__
21+
// |___/\___|_| \_/ |_|\___\___| |_| \___/|_| \__,_|\___| \_/ \___|_|\___/| .__/ \___|_| |___/
22+
// ______ ______ ______ ______ ______ ______ ______ ______ | |
23+
// |______|______|______|______|______|______|______|______| |_|
24+
//
25+
26+
27+
#import "CASJobParameters.h"
28+
29+
30+
31+
NS_ASSUME_NONNULL_BEGIN
32+
@implementation CASJobParameters
33+
34+
35+
36+
+ (NSDictionary *)modelCustomPropertyMapper
37+
{
38+
return @{
39+
@"tier" :@"Tier",
40+
};
41+
}
42+
43+
44+
- (BOOL)modelCustomTransformToDictionary:(NSMutableDictionary *)dic
45+
{
46+
47+
NSNumber* CASTierenumValue = dic[@"Tier"];
48+
if (CASTierenumValue) {
49+
NSString* value = QCloudCASTierTransferToString([CASTierenumValue intValue]);
50+
if (value) {
51+
dic[@"Tier"] = value;
52+
}
53+
}
54+
55+
return YES;
56+
}
57+
58+
- (NSDictionary *)modelCustomWillTransformFromDictionary:(NSDictionary *)dic
59+
{
60+
if (!dic) {
61+
return dic;
62+
}
63+
NSMutableDictionary* transfromDic = [NSMutableDictionary dictionaryWithDictionary:dic];
64+
65+
NSString* CASTierenumValue = transfromDic[@"Tier"];
66+
if (CASTierenumValue && [CASTierenumValue isKindOfClass:[NSString class]] && CASTierenumValue.length > 0) {
67+
int value = QCloudCASTierDumpFromString(CASTierenumValue);
68+
transfromDic[@"Tier"] = @(value);
69+
}
70+
return transfromDic;
71+
}
72+
73+
@end
74+
75+
76+
NS_ASSUME_NONNULL_END

QCloudCOSXML/Classes/Manager/QCloudBucketReplicationRule.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,15 +27,15 @@
2727

2828
#import <Foundation/Foundation.h>
2929
#import <QCloudCore/QCloudCore.h>
30-
#import "QCloudQCloudCOSXMLStatusEnum.h"
30+
#import "QCloudCOSXMLStatusEnum.h"
3131
#import "QCloudBucketReplicationDestination.h"
3232

3333
NS_ASSUME_NONNULL_BEGIN
3434
@interface QCloudBucketReplicationRule : NSObject
3535
/**
3636
标志Rule是否生效
3737
*/
38-
@property (assign, nonatomic) QCloudQCloudCOSXMLStatus status;
38+
@property (assign, nonatomic) QCloudCOSXMLStatus status;
3939
/**
4040
用来标注具体rule的名称
4141
*/

0 commit comments

Comments
 (0)