Skip to content

Commit 7f92a01

Browse files
committed
Merge pull request #146 from longbai/hide_gtm_name
隐藏gtm base64 class
2 parents 39632b3 + e557041 commit 7f92a01

File tree

8 files changed

+48
-36
lines changed

8 files changed

+48
-36
lines changed

CHANGELOG.md

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,18 @@
11
#Changelog
22

3+
## 7.0.17 (2016-04-21)
4+
5+
### 修正
6+
* 进度回调有时显示回退
7+
* 隐藏GTM_Base64 类名,避免名字冲突
8+
* 暂时去除QNStat
9+
* 分片上传的fname
10+
11+
### 增加
12+
* 从bundle 中读取 ats 配置
13+
* 增加格式化脚本,格式化所有代码
14+
* 增加了一个从相册选取文件上传的demo
15+
316
## 7.0.16 (2015-11-21)
417

518
### 修正

Qiniu.podspec

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
Pod::Spec.new do |s|
22
s.name = 'Qiniu'
3-
s.version = '7.0.16'
3+
s.version = '7.0.17'
44
s.summary = 'Qiniu Resource Storage SDK for iOS and Mac'
55
s.homepage = 'https://github.com/qiniu/objc-sdk'
66
s.social_media_url = 'http://weibo.com/qiniutek'

QiniuSDK.xcodeproj/project.pbxproj

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -62,9 +62,9 @@
6262
DF2CDE6B19DAC6A400CE01FB /* QNUploadManager.m in Sources */ = {isa = PBXBuildFile; fileRef = DF2CDE5B19DAC6A400CE01FB /* QNUploadManager.m */; };
6363
DF2CDE7119DAE90300CE01FB /* QNBase64Test.m in Sources */ = {isa = PBXBuildFile; fileRef = DF2CDE7019DAE90300CE01FB /* QNBase64Test.m */; };
6464
DF3C504A19DD7D9F000F548F /* QNResumeUploadTest.m in Sources */ = {isa = PBXBuildFile; fileRef = DF3C504919DD7D9F000F548F /* QNResumeUploadTest.m */; };
65-
DF437CD21B2426270099587B /* GTM_Base64.h in Headers */ = {isa = PBXBuildFile; fileRef = DF437CD01B2426270099587B /* GTM_Base64.h */; };
66-
DF437CD31B2426270099587B /* GTM_Base64.m in Sources */ = {isa = PBXBuildFile; fileRef = DF437CD11B2426270099587B /* GTM_Base64.m */; };
67-
DF437CD51B2426270099587B /* GTM_Base64.m in Sources */ = {isa = PBXBuildFile; fileRef = DF437CD11B2426270099587B /* GTM_Base64.m */; };
65+
DF437CD21B2426270099587B /* QN_GTM_Base64.h in Headers */ = {isa = PBXBuildFile; fileRef = DF437CD01B2426270099587B /* QN_GTM_Base64.h */; };
66+
DF437CD31B2426270099587B /* QN_GTM_Base64.m in Sources */ = {isa = PBXBuildFile; fileRef = DF437CD11B2426270099587B /* QN_GTM_Base64.m */; };
67+
DF437CD51B2426270099587B /* QN_GTM_Base64.m in Sources */ = {isa = PBXBuildFile; fileRef = DF437CD11B2426270099587B /* QN_GTM_Base64.m */; };
6868
DF437CD91B2429E10099587B /* QNUpToken.h in Headers */ = {isa = PBXBuildFile; fileRef = DF437CD71B2429E10099587B /* QNUpToken.h */; };
6969
DF437CDA1B2429E10099587B /* QNUpToken.m in Sources */ = {isa = PBXBuildFile; fileRef = DF437CD81B2429E10099587B /* QNUpToken.m */; };
7070
DF437CDC1B2429E10099587B /* QNUpToken.m in Sources */ = {isa = PBXBuildFile; fileRef = DF437CD81B2429E10099587B /* QNUpToken.m */; };
@@ -170,8 +170,8 @@
170170
DF2CDE7019DAE90300CE01FB /* QNBase64Test.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = QNBase64Test.m; sourceTree = "<group>"; };
171171
DF3C504619DD7BA6000F548F /* QNFormUploadTest.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = QNFormUploadTest.m; sourceTree = "<group>"; };
172172
DF3C504919DD7D9F000F548F /* QNResumeUploadTest.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = QNResumeUploadTest.m; sourceTree = "<group>"; };
173-
DF437CD01B2426270099587B /* GTM_Base64.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = GTM_Base64.h; sourceTree = "<group>"; };
174-
DF437CD11B2426270099587B /* GTM_Base64.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = GTM_Base64.m; sourceTree = "<group>"; };
173+
DF437CD01B2426270099587B /* QN_GTM_Base64.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = QN_GTM_Base64.h; sourceTree = "<group>"; };
174+
DF437CD11B2426270099587B /* QN_GTM_Base64.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = QN_GTM_Base64.m; sourceTree = "<group>"; };
175175
DF437CD71B2429E10099587B /* QNUpToken.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = QNUpToken.h; sourceTree = "<group>"; };
176176
DF437CD81B2429E10099587B /* QNUpToken.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = QNUpToken.m; sourceTree = "<group>"; };
177177
DF437CDE1B243A2C0099587B /* QNUpTokenTest.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = QNUpTokenTest.m; sourceTree = "<group>"; };
@@ -348,8 +348,8 @@
348348
DF2CDE5719DAC6A400CE01FB /* QNVersion.h */,
349349
DFA9B63919DF904000A15FD1 /* QNEtag.h */,
350350
DFA9B63A19DF904000A15FD1 /* QNEtag.m */,
351-
DF437CD01B2426270099587B /* GTM_Base64.h */,
352-
DF437CD11B2426270099587B /* GTM_Base64.m */,
351+
DF437CD01B2426270099587B /* QN_GTM_Base64.h */,
352+
DF437CD11B2426270099587B /* QN_GTM_Base64.m */,
353353
DFF126ED1B63909A0005C39C /* QNFileDelegate.h */,
354354
DFF126EF1B639F3B0005C39C /* QNFile.h */,
355355
DFF126F01B639F3B0005C39C /* QNFile.m */,
@@ -426,7 +426,7 @@
426426
DFBF63711BCCE2A600A771D8 /* QNSystem.h in Headers */,
427427
DFF126F61B63ABED0005C39C /* QNALAssetFile.h in Headers */,
428428
DF6099FA1A5676AA00AC7297 /* QNDns.h in Headers */,
429-
DF437CD21B2426270099587B /* GTM_Base64.h in Headers */,
429+
DF437CD21B2426270099587B /* QN_GTM_Base64.h in Headers */,
430430
DF293C9E19DBC2AE00799011 /* QNUserAgent.h in Headers */,
431431
DF2CDE6719DAC6A400CE01FB /* QNVersion.h in Headers */,
432432
DF293CA419DC04C200799011 /* QNHttpManager.h in Headers */,
@@ -723,7 +723,7 @@
723723
DFBF636E1BCCE28300A771D8 /* QNSystem.m in Sources */,
724724
DF0D23CF19DCE6E500D6B68F /* QNResponseInfo.m in Sources */,
725725
DFA9B63C19DF904000A15FD1 /* QNEtag.m in Sources */,
726-
DF437CD31B2426270099587B /* GTM_Base64.m in Sources */,
726+
DF437CD31B2426270099587B /* QN_GTM_Base64.m in Sources */,
727727
DF482FD91B0DA8A2000DAD98 /* QNConfiguration.m in Sources */,
728728
DF609A061A58E39D00AC7297 /* QNFormUpload.m in Sources */,
729729
DF293C9F19DBC2AE00799011 /* QNUserAgent.m in Sources */,
@@ -772,7 +772,7 @@
772772
DF2CDE5E19DAC6A400CE01FB /* QNUrlSafeBase64.m in Sources */,
773773
DF0D23D019DCE6E500D6B68F /* QNResponseInfo.m in Sources */,
774774
DFA9B63D19DF904000A15FD1 /* QNEtag.m in Sources */,
775-
DF437CD51B2426270099587B /* GTM_Base64.m in Sources */,
775+
DF437CD51B2426270099587B /* QN_GTM_Base64.m in Sources */,
776776
DF482FDA1B0DA8A2000DAD98 /* QNConfiguration.m in Sources */,
777777
DF609A081A58E39D00AC7297 /* QNFormUpload.m in Sources */,
778778
93CEF4801BDE11FF00750FE8 /* QNPHAssetFile.m in Sources */,

QiniuSDK/Common/QNUrlSafeBase64.m

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99

1010
#import "QNUrlSafeBase64.h"
1111

12-
#import "GTM_Base64.h"
12+
#import "QN_GTM_Base64.h"
1313

1414
@implementation QNUrlSafeBase64
1515

@@ -19,11 +19,11 @@ + (NSString *)encodeString:(NSString *)sourceString {
1919
}
2020

2121
+ (NSString *)encodeData:(NSData *)data {
22-
return [GTM_Base64 stringByWebSafeEncodingData:data padded:YES];
22+
return [QN_GTM_Base64 stringByWebSafeEncodingData:data padded:YES];
2323
}
2424

2525
+ (NSData *)decodeString:(NSString *)data {
26-
return [GTM_Base64 webSafeDecodeString:data];
26+
return [QN_GTM_Base64 webSafeDecodeString:data];
2727
}
2828

2929
@end

QiniuSDK/Common/GTM_Base64.h renamed to QiniuSDK/Common/QN_GTM_Base64.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
/// encoding. You must use the webSafe* methods together, the data does not
2929
/// interop with the RFC methods.
3030
//
31-
@interface GTM_Base64 : NSObject
31+
@interface QN_GTM_Base64 : NSObject
3232

3333
//
3434
// Standard Base64 (RFC) handling

QiniuSDK/Common/GTM_Base64.m renamed to QiniuSDK/Common/QN_GTM_Base64.m

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
// the License.
1717
//
1818

19-
#import "GTM_Base64.h"
19+
#import "QN_GTM_Base64.h"
2020

2121
static const char *kBase64EncodeChars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
2222
static const char *kWebSafeBase64EncodeChars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_";
@@ -149,7 +149,7 @@
149149
// YES if the character is a whitespace character.
150150
// NO if the character is not a whitespace character.
151151
//
152-
BOOL IsSpace(unsigned char c) {
152+
BOOL QN_IsSpace(unsigned char c) {
153153
// we use our own mapping here because we don't want anything w/ locale
154154
// support.
155155
static BOOL kSpaces[256] = {
@@ -188,7 +188,7 @@ BOOL IsSpace(unsigned char c) {
188188
// Returns:
189189
// The guessed encoded length for a source length
190190
//
191-
NSUInteger CalcEncodedLength(NSUInteger srcLen, BOOL padded) {
191+
NSUInteger QN_CalcEncodedLength(NSUInteger srcLen, BOOL padded) {
192192
NSUInteger intermediate_result = 8 * srcLen + 5;
193193
NSUInteger len = intermediate_result / 6;
194194
if (padded) {
@@ -204,11 +204,11 @@ NSUInteger CalcEncodedLength(NSUInteger srcLen, BOOL padded) {
204204
// Returns:
205205
// The guessed decoded length for a source length
206206
//
207-
NSUInteger GuessDecodedLength(NSUInteger srcLen) {
207+
NSUInteger QN_GuessDecodedLength(NSUInteger srcLen) {
208208
return (srcLen + 3) / 4 * 3;
209209
}
210210

211-
@interface GTM_Base64 (PrivateMethods)
211+
@interface QN_GTM_Base64 (PrivateMethods)
212212

213213
+ (NSData *)baseEncode:(const void *)bytes
214214
length:(NSUInteger)length
@@ -236,7 +236,7 @@ + (NSUInteger)baseDecode:(const char *)srcBytes
236236

237237
@end
238238

239-
@implementation GTM_Base64
239+
@implementation QN_GTM_Base64
240240

241241
//
242242
// Standard Base64 (RFC) handling
@@ -391,7 +391,7 @@ + (NSData *)webSafeDecodeString:(NSString *)string {
391391

392392
@end
393393

394-
@implementation GTM_Base64 (PrivateMethods)
394+
@implementation QN_GTM_Base64 (PrivateMethods)
395395

396396
//
397397
// baseEncode:length:charset:padded:
@@ -409,7 +409,7 @@ + (NSData *)baseEncode:(const void *)bytes
409409
charset:(const char *)charset
410410
padded:(BOOL)padded {
411411
// how big could it be?
412-
NSUInteger maxLength = CalcEncodedLength(length, padded);
412+
NSUInteger maxLength = QN_CalcEncodedLength(length, padded);
413413
// make space
414414
NSMutableData *result = [NSMutableData data];
415415
[result setLength:maxLength];
@@ -445,7 +445,7 @@ + (NSData *)baseDecode:(const void *)bytes
445445
charset:(const char *)charset
446446
requirePadding:(BOOL)requirePadding {
447447
// could try to calculate what it will end up as
448-
NSUInteger maxLength = GuessDecodedLength(length);
448+
NSUInteger maxLength = QN_GuessDecodedLength(length);
449449
// make space
450450
NSMutableData *result = [NSMutableData data];
451451
[result setLength:maxLength];
@@ -575,7 +575,7 @@ + (NSUInteger)baseDecode:(const char *)srcBytes
575575
int state = 0;
576576
char ch = 0;
577577
while (srcLen-- && (ch = *srcBytes++) != 0) {
578-
if (IsSpace(ch)) // Skip whitespace
578+
if (QN_IsSpace(ch)) // Skip whitespace
579579
continue;
580580

581581
if (ch == kBase64PaddingChar)
@@ -648,7 +648,7 @@ + (NSUInteger)baseDecode:(const char *)srcBytes
648648
} else {
649649
if (state == 2) { // need another '='
650650
while ((ch = *srcBytes++) && (srcLen-- > 0)) {
651-
if (!IsSpace(ch))
651+
if (!QN_IsSpace(ch))
652652
break;
653653
}
654654
if (ch != kBase64PaddingChar) {
@@ -657,7 +657,7 @@ + (NSUInteger)baseDecode:(const char *)srcBytes
657657
}
658658
// state = 1 or 2, check if all remain padding is space
659659
while ((ch = *srcBytes++) && (srcLen-- > 0)) {
660-
if (!IsSpace(ch)) {
660+
if (!QN_IsSpace(ch)) {
661661
return 0;
662662
}
663663
}

QiniuSDK/Storage/QNResumeUpload.m

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ @interface QNResumeUpload ()
4040

4141
@property (nonatomic, strong) id<QNFileDelegate> file;
4242

43-
@property (nonatomic, strong) NSArray *fileAry;
43+
//@property (nonatomic, strong) NSArray *fileAry;
4444

4545
@property (nonatomic) float previousPercent;
4646

@@ -303,7 +303,7 @@ - (void)makeFile:(NSString *)uphost
303303
}];
304304

305305
//添加路径
306-
NSString *fname = [[NSString alloc] initWithFormat:@"/fname/%@", [QNUrlSafeBase64 encodeString:[self dealFilePath]]];
306+
NSString *fname = [[NSString alloc] initWithFormat:@"/fname/%@", [QNUrlSafeBase64 encodeString:[self fileBaseName]]];
307307
url = [NSString stringWithFormat:@"%@%@", url, fname];
308308

309309
NSMutableData *postData = [NSMutableData data];
@@ -313,13 +313,8 @@ - (void)makeFile:(NSString *)uphost
313313
}
314314

315315
#pragma mark - 处理文件路径
316-
- (NSString *)dealFilePath {
317-
318-
_fileAry = [NSArray array];
319-
NSString *filePath = [_file path];
320-
_fileAry = [filePath componentsSeparatedByString:@"/"];
321-
NSString *fname = [_fileAry objectAtIndex:(_fileAry.count - 1)];
322-
return fname;
316+
- (NSString *)fileBaseName {
317+
return [[_file path] lastPathComponent];
323318
}
324319

325320
- (void)post:(NSString *)url

README.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,10 @@ $ xctool -workspace QiniuSDK.xcworkspace -scheme "QiniuSDK Mac" -sdk macosx -con
5656
$ xctool -workspace QiniuSDK.xcworkspace -scheme "QiniuSDK Mac" -sdk macosx -configuration Debug test -test-sdk macosx -only "QiniuSDK MacTests:QNResumeUploadTest/test500k"
5757
```
5858

59+
## 示例代码
60+
* 完整的demo 见 QiniuDemo 目录下的代码
61+
* 具体细节的一些配置 可参考 QiniuSDKTests 下面的一些单元测试,以及源代码
62+
5963
## 常见问题
6064

6165
- 如果碰到 crc 链接错误, 请把 libz.dylib 加入到项目中去

0 commit comments

Comments
 (0)