diff --git a/CHANGELOG.md b/CHANGELOG.md index ad6f9eed..3b27fa8e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,18 @@ #Changelog +## 7.0.17 (2016-04-21) + +### 修正 +* 进度回调有时显示回退 +* 隐藏GTM_Base64 类名,避免名字冲突 +* 暂时去除QNStat +* 分片上传的fname + +### 增加 +* 从bundle 中读取 ats 配置 +* 增加格式化脚本,格式化所有代码 +* 增加了一个从相册选取文件上传的demo + ## 7.0.16 (2015-11-21) ### 修正 diff --git a/Qiniu.podspec b/Qiniu.podspec index 7b4acc0c..6b2c7149 100644 --- a/Qiniu.podspec +++ b/Qiniu.podspec @@ -1,6 +1,6 @@ Pod::Spec.new do |s| s.name = 'Qiniu' - s.version = '7.0.16' + s.version = '7.0.17' s.summary = 'Qiniu Resource Storage SDK for iOS and Mac' s.homepage = 'https://github.com/qiniu/objc-sdk' s.social_media_url = 'http://weibo.com/qiniutek' diff --git a/QiniuSDK.xcodeproj/project.pbxproj b/QiniuSDK.xcodeproj/project.pbxproj index 3e0186ca..92200124 100644 --- a/QiniuSDK.xcodeproj/project.pbxproj +++ b/QiniuSDK.xcodeproj/project.pbxproj @@ -62,9 +62,9 @@ DF2CDE6B19DAC6A400CE01FB /* QNUploadManager.m in Sources */ = {isa = PBXBuildFile; fileRef = DF2CDE5B19DAC6A400CE01FB /* QNUploadManager.m */; }; DF2CDE7119DAE90300CE01FB /* QNBase64Test.m in Sources */ = {isa = PBXBuildFile; fileRef = DF2CDE7019DAE90300CE01FB /* QNBase64Test.m */; }; DF3C504A19DD7D9F000F548F /* QNResumeUploadTest.m in Sources */ = {isa = PBXBuildFile; fileRef = DF3C504919DD7D9F000F548F /* QNResumeUploadTest.m */; }; - DF437CD21B2426270099587B /* GTM_Base64.h in Headers */ = {isa = PBXBuildFile; fileRef = DF437CD01B2426270099587B /* GTM_Base64.h */; }; - DF437CD31B2426270099587B /* GTM_Base64.m in Sources */ = {isa = PBXBuildFile; fileRef = DF437CD11B2426270099587B /* GTM_Base64.m */; }; - DF437CD51B2426270099587B /* GTM_Base64.m in Sources */ = {isa = PBXBuildFile; fileRef = DF437CD11B2426270099587B /* GTM_Base64.m */; }; + DF437CD21B2426270099587B /* QN_GTM_Base64.h in Headers */ = {isa = PBXBuildFile; fileRef = DF437CD01B2426270099587B /* QN_GTM_Base64.h */; }; + DF437CD31B2426270099587B /* QN_GTM_Base64.m in Sources */ = {isa = PBXBuildFile; fileRef = DF437CD11B2426270099587B /* QN_GTM_Base64.m */; }; + DF437CD51B2426270099587B /* QN_GTM_Base64.m in Sources */ = {isa = PBXBuildFile; fileRef = DF437CD11B2426270099587B /* QN_GTM_Base64.m */; }; DF437CD91B2429E10099587B /* QNUpToken.h in Headers */ = {isa = PBXBuildFile; fileRef = DF437CD71B2429E10099587B /* QNUpToken.h */; }; DF437CDA1B2429E10099587B /* QNUpToken.m in Sources */ = {isa = PBXBuildFile; fileRef = DF437CD81B2429E10099587B /* QNUpToken.m */; }; DF437CDC1B2429E10099587B /* QNUpToken.m in Sources */ = {isa = PBXBuildFile; fileRef = DF437CD81B2429E10099587B /* QNUpToken.m */; }; @@ -170,8 +170,8 @@ DF2CDE7019DAE90300CE01FB /* QNBase64Test.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = QNBase64Test.m; sourceTree = ""; }; DF3C504619DD7BA6000F548F /* QNFormUploadTest.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = QNFormUploadTest.m; sourceTree = ""; }; DF3C504919DD7D9F000F548F /* QNResumeUploadTest.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = QNResumeUploadTest.m; sourceTree = ""; }; - DF437CD01B2426270099587B /* GTM_Base64.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = GTM_Base64.h; sourceTree = ""; }; - DF437CD11B2426270099587B /* GTM_Base64.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = GTM_Base64.m; sourceTree = ""; }; + DF437CD01B2426270099587B /* QN_GTM_Base64.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = QN_GTM_Base64.h; sourceTree = ""; }; + DF437CD11B2426270099587B /* QN_GTM_Base64.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = QN_GTM_Base64.m; sourceTree = ""; }; DF437CD71B2429E10099587B /* QNUpToken.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = QNUpToken.h; sourceTree = ""; }; DF437CD81B2429E10099587B /* QNUpToken.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = QNUpToken.m; sourceTree = ""; }; DF437CDE1B243A2C0099587B /* QNUpTokenTest.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = QNUpTokenTest.m; sourceTree = ""; }; @@ -348,8 +348,8 @@ DF2CDE5719DAC6A400CE01FB /* QNVersion.h */, DFA9B63919DF904000A15FD1 /* QNEtag.h */, DFA9B63A19DF904000A15FD1 /* QNEtag.m */, - DF437CD01B2426270099587B /* GTM_Base64.h */, - DF437CD11B2426270099587B /* GTM_Base64.m */, + DF437CD01B2426270099587B /* QN_GTM_Base64.h */, + DF437CD11B2426270099587B /* QN_GTM_Base64.m */, DFF126ED1B63909A0005C39C /* QNFileDelegate.h */, DFF126EF1B639F3B0005C39C /* QNFile.h */, DFF126F01B639F3B0005C39C /* QNFile.m */, @@ -426,7 +426,7 @@ DFBF63711BCCE2A600A771D8 /* QNSystem.h in Headers */, DFF126F61B63ABED0005C39C /* QNALAssetFile.h in Headers */, DF6099FA1A5676AA00AC7297 /* QNDns.h in Headers */, - DF437CD21B2426270099587B /* GTM_Base64.h in Headers */, + DF437CD21B2426270099587B /* QN_GTM_Base64.h in Headers */, DF293C9E19DBC2AE00799011 /* QNUserAgent.h in Headers */, DF2CDE6719DAC6A400CE01FB /* QNVersion.h in Headers */, DF293CA419DC04C200799011 /* QNHttpManager.h in Headers */, @@ -723,7 +723,7 @@ DFBF636E1BCCE28300A771D8 /* QNSystem.m in Sources */, DF0D23CF19DCE6E500D6B68F /* QNResponseInfo.m in Sources */, DFA9B63C19DF904000A15FD1 /* QNEtag.m in Sources */, - DF437CD31B2426270099587B /* GTM_Base64.m in Sources */, + DF437CD31B2426270099587B /* QN_GTM_Base64.m in Sources */, DF482FD91B0DA8A2000DAD98 /* QNConfiguration.m in Sources */, DF609A061A58E39D00AC7297 /* QNFormUpload.m in Sources */, DF293C9F19DBC2AE00799011 /* QNUserAgent.m in Sources */, @@ -772,7 +772,7 @@ DF2CDE5E19DAC6A400CE01FB /* QNUrlSafeBase64.m in Sources */, DF0D23D019DCE6E500D6B68F /* QNResponseInfo.m in Sources */, DFA9B63D19DF904000A15FD1 /* QNEtag.m in Sources */, - DF437CD51B2426270099587B /* GTM_Base64.m in Sources */, + DF437CD51B2426270099587B /* QN_GTM_Base64.m in Sources */, DF482FDA1B0DA8A2000DAD98 /* QNConfiguration.m in Sources */, DF609A081A58E39D00AC7297 /* QNFormUpload.m in Sources */, 93CEF4801BDE11FF00750FE8 /* QNPHAssetFile.m in Sources */, diff --git a/QiniuSDK/Common/QNUrlSafeBase64.m b/QiniuSDK/Common/QNUrlSafeBase64.m index 73f22aec..0079c24e 100644 --- a/QiniuSDK/Common/QNUrlSafeBase64.m +++ b/QiniuSDK/Common/QNUrlSafeBase64.m @@ -9,7 +9,7 @@ #import "QNUrlSafeBase64.h" -#import "GTM_Base64.h" +#import "QN_GTM_Base64.h" @implementation QNUrlSafeBase64 @@ -19,11 +19,11 @@ + (NSString *)encodeString:(NSString *)sourceString { } + (NSString *)encodeData:(NSData *)data { - return [GTM_Base64 stringByWebSafeEncodingData:data padded:YES]; + return [QN_GTM_Base64 stringByWebSafeEncodingData:data padded:YES]; } + (NSData *)decodeString:(NSString *)data { - return [GTM_Base64 webSafeDecodeString:data]; + return [QN_GTM_Base64 webSafeDecodeString:data]; } @end diff --git a/QiniuSDK/Common/GTM_Base64.h b/QiniuSDK/Common/QN_GTM_Base64.h similarity index 99% rename from QiniuSDK/Common/GTM_Base64.h rename to QiniuSDK/Common/QN_GTM_Base64.h index edd413b5..096a2344 100644 --- a/QiniuSDK/Common/GTM_Base64.h +++ b/QiniuSDK/Common/QN_GTM_Base64.h @@ -28,7 +28,7 @@ /// encoding. You must use the webSafe* methods together, the data does not /// interop with the RFC methods. // -@interface GTM_Base64 : NSObject +@interface QN_GTM_Base64 : NSObject // // Standard Base64 (RFC) handling diff --git a/QiniuSDK/Common/GTM_Base64.m b/QiniuSDK/Common/QN_GTM_Base64.m similarity index 97% rename from QiniuSDK/Common/GTM_Base64.m rename to QiniuSDK/Common/QN_GTM_Base64.m index f1f91f2e..57edcc9d 100644 --- a/QiniuSDK/Common/GTM_Base64.m +++ b/QiniuSDK/Common/QN_GTM_Base64.m @@ -16,7 +16,7 @@ // the License. // -#import "GTM_Base64.h" +#import "QN_GTM_Base64.h" static const char *kBase64EncodeChars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"; static const char *kWebSafeBase64EncodeChars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_"; @@ -149,7 +149,7 @@ // YES if the character is a whitespace character. // NO if the character is not a whitespace character. // -BOOL IsSpace(unsigned char c) { +BOOL QN_IsSpace(unsigned char c) { // we use our own mapping here because we don't want anything w/ locale // support. static BOOL kSpaces[256] = { @@ -188,7 +188,7 @@ BOOL IsSpace(unsigned char c) { // Returns: // The guessed encoded length for a source length // -NSUInteger CalcEncodedLength(NSUInteger srcLen, BOOL padded) { +NSUInteger QN_CalcEncodedLength(NSUInteger srcLen, BOOL padded) { NSUInteger intermediate_result = 8 * srcLen + 5; NSUInteger len = intermediate_result / 6; if (padded) { @@ -204,11 +204,11 @@ NSUInteger CalcEncodedLength(NSUInteger srcLen, BOOL padded) { // Returns: // The guessed decoded length for a source length // -NSUInteger GuessDecodedLength(NSUInteger srcLen) { +NSUInteger QN_GuessDecodedLength(NSUInteger srcLen) { return (srcLen + 3) / 4 * 3; } -@interface GTM_Base64 (PrivateMethods) +@interface QN_GTM_Base64 (PrivateMethods) + (NSData *)baseEncode:(const void *)bytes length:(NSUInteger)length @@ -236,7 +236,7 @@ + (NSUInteger)baseDecode:(const char *)srcBytes @end -@implementation GTM_Base64 +@implementation QN_GTM_Base64 // // Standard Base64 (RFC) handling @@ -391,7 +391,7 @@ + (NSData *)webSafeDecodeString:(NSString *)string { @end -@implementation GTM_Base64 (PrivateMethods) +@implementation QN_GTM_Base64 (PrivateMethods) // // baseEncode:length:charset:padded: @@ -409,7 +409,7 @@ + (NSData *)baseEncode:(const void *)bytes charset:(const char *)charset padded:(BOOL)padded { // how big could it be? - NSUInteger maxLength = CalcEncodedLength(length, padded); + NSUInteger maxLength = QN_CalcEncodedLength(length, padded); // make space NSMutableData *result = [NSMutableData data]; [result setLength:maxLength]; @@ -445,7 +445,7 @@ + (NSData *)baseDecode:(const void *)bytes charset:(const char *)charset requirePadding:(BOOL)requirePadding { // could try to calculate what it will end up as - NSUInteger maxLength = GuessDecodedLength(length); + NSUInteger maxLength = QN_GuessDecodedLength(length); // make space NSMutableData *result = [NSMutableData data]; [result setLength:maxLength]; @@ -575,7 +575,7 @@ + (NSUInteger)baseDecode:(const char *)srcBytes int state = 0; char ch = 0; while (srcLen-- && (ch = *srcBytes++) != 0) { - if (IsSpace(ch)) // Skip whitespace + if (QN_IsSpace(ch)) // Skip whitespace continue; if (ch == kBase64PaddingChar) @@ -648,7 +648,7 @@ + (NSUInteger)baseDecode:(const char *)srcBytes } else { if (state == 2) { // need another '=' while ((ch = *srcBytes++) && (srcLen-- > 0)) { - if (!IsSpace(ch)) + if (!QN_IsSpace(ch)) break; } if (ch != kBase64PaddingChar) { @@ -657,7 +657,7 @@ + (NSUInteger)baseDecode:(const char *)srcBytes } // state = 1 or 2, check if all remain padding is space while ((ch = *srcBytes++) && (srcLen-- > 0)) { - if (!IsSpace(ch)) { + if (!QN_IsSpace(ch)) { return 0; } } diff --git a/QiniuSDK/Storage/QNResumeUpload.m b/QiniuSDK/Storage/QNResumeUpload.m index 47d408ef..49a3bbb6 100644 --- a/QiniuSDK/Storage/QNResumeUpload.m +++ b/QiniuSDK/Storage/QNResumeUpload.m @@ -40,7 +40,7 @@ @interface QNResumeUpload () @property (nonatomic, strong) id file; -@property (nonatomic, strong) NSArray *fileAry; +//@property (nonatomic, strong) NSArray *fileAry; @property (nonatomic) float previousPercent; @@ -303,7 +303,7 @@ - (void)makeFile:(NSString *)uphost }]; //添加路径 - NSString *fname = [[NSString alloc] initWithFormat:@"/fname/%@", [QNUrlSafeBase64 encodeString:[self dealFilePath]]]; + NSString *fname = [[NSString alloc] initWithFormat:@"/fname/%@", [QNUrlSafeBase64 encodeString:[self fileBaseName]]]; url = [NSString stringWithFormat:@"%@%@", url, fname]; NSMutableData *postData = [NSMutableData data]; @@ -313,13 +313,8 @@ - (void)makeFile:(NSString *)uphost } #pragma mark - 处理文件路径 -- (NSString *)dealFilePath { - - _fileAry = [NSArray array]; - NSString *filePath = [_file path]; - _fileAry = [filePath componentsSeparatedByString:@"/"]; - NSString *fname = [_fileAry objectAtIndex:(_fileAry.count - 1)]; - return fname; +- (NSString *)fileBaseName { + return [[_file path] lastPathComponent]; } - (void)post:(NSString *)url diff --git a/README.md b/README.md index 8beb3733..c0e467b7 100644 --- a/README.md +++ b/README.md @@ -56,6 +56,10 @@ $ xctool -workspace QiniuSDK.xcworkspace -scheme "QiniuSDK Mac" -sdk macosx -con $ xctool -workspace QiniuSDK.xcworkspace -scheme "QiniuSDK Mac" -sdk macosx -configuration Debug test -test-sdk macosx -only "QiniuSDK MacTests:QNResumeUploadTest/test500k" ``` +## 示例代码 +* 完整的demo 见 QiniuDemo 目录下的代码 +* 具体细节的一些配置 可参考 QiniuSDKTests 下面的一些单元测试,以及源代码 + ## 常见问题 - 如果碰到 crc 链接错误, 请把 libz.dylib 加入到项目中去