Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,18 @@
#Changelog

## 7.0.17 (2016-04-21)

### 修正
* 进度回调有时显示回退
* 隐藏GTM_Base64 类名,避免名字冲突
* 暂时去除QNStat
* 分片上传的fname

### 增加
* 从bundle 中读取 ats 配置
* 增加格式化脚本,格式化所有代码
* 增加了一个从相册选取文件上传的demo

## 7.0.16 (2015-11-21)

### 修正
Expand Down
2 changes: 1 addition & 1 deletion Qiniu.podspec
Original file line number Diff line number Diff line change
@@ -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'
Expand Down
20 changes: 10 additions & 10 deletions QiniuSDK.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -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 */; };
Expand Down Expand Up @@ -170,8 +170,8 @@
DF2CDE7019DAE90300CE01FB /* QNBase64Test.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = QNBase64Test.m; sourceTree = "<group>"; };
DF3C504619DD7BA6000F548F /* QNFormUploadTest.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = QNFormUploadTest.m; sourceTree = "<group>"; };
DF3C504919DD7D9F000F548F /* QNResumeUploadTest.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = QNResumeUploadTest.m; sourceTree = "<group>"; };
DF437CD01B2426270099587B /* GTM_Base64.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = GTM_Base64.h; sourceTree = "<group>"; };
DF437CD11B2426270099587B /* GTM_Base64.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = GTM_Base64.m; sourceTree = "<group>"; };
DF437CD01B2426270099587B /* QN_GTM_Base64.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = QN_GTM_Base64.h; sourceTree = "<group>"; };
DF437CD11B2426270099587B /* QN_GTM_Base64.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = QN_GTM_Base64.m; sourceTree = "<group>"; };
DF437CD71B2429E10099587B /* QNUpToken.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = QNUpToken.h; sourceTree = "<group>"; };
DF437CD81B2429E10099587B /* QNUpToken.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = QNUpToken.m; sourceTree = "<group>"; };
DF437CDE1B243A2C0099587B /* QNUpTokenTest.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = QNUpTokenTest.m; sourceTree = "<group>"; };
Expand Down Expand Up @@ -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 */,
Expand Down Expand Up @@ -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 */,
Expand Down Expand Up @@ -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 */,
Expand Down Expand Up @@ -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 */,
Expand Down
6 changes: 3 additions & 3 deletions QiniuSDK/Common/QNUrlSafeBase64.m
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

#import "QNUrlSafeBase64.h"

#import "GTM_Base64.h"
#import "QN_GTM_Base64.h"

@implementation QNUrlSafeBase64

Expand All @@ -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
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
24 changes: 12 additions & 12 deletions QiniuSDK/Common/GTM_Base64.m → QiniuSDK/Common/QN_GTM_Base64.m
Original file line number Diff line number Diff line change
Expand Up @@ -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-_";
Expand Down Expand Up @@ -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] = {
Expand Down Expand Up @@ -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) {
Expand All @@ -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
Expand Down Expand Up @@ -236,7 +236,7 @@ + (NSUInteger)baseDecode:(const char *)srcBytes

@end

@implementation GTM_Base64
@implementation QN_GTM_Base64

//
// Standard Base64 (RFC) handling
Expand Down Expand Up @@ -391,7 +391,7 @@ + (NSData *)webSafeDecodeString:(NSString *)string {

@end

@implementation GTM_Base64 (PrivateMethods)
@implementation QN_GTM_Base64 (PrivateMethods)

//
// baseEncode:length:charset:padded:
Expand All @@ -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];
Expand Down Expand Up @@ -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];
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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) {
Expand All @@ -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;
}
}
Expand Down
13 changes: 4 additions & 9 deletions QiniuSDK/Storage/QNResumeUpload.m
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ @interface QNResumeUpload ()

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

@property (nonatomic, strong) NSArray *fileAry;
//@property (nonatomic, strong) NSArray *fileAry;

@property (nonatomic) float previousPercent;

Expand Down Expand Up @@ -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];
Expand All @@ -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
Expand Down
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 加入到项目中去
Expand Down