Skip to content

Commit

Permalink
Merge pull request #212 from longbai/us_zone
Browse files Browse the repository at this point in the history
Us zone
  • Loading branch information
longbai authored Nov 7, 2016
2 parents ba91cb5 + c47714d commit b5734ed
Show file tree
Hide file tree
Showing 13 changed files with 178 additions and 165 deletions.
6 changes: 5 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
#Changelog

## 7.1.3 (2016-11-07)
## 增加
* 增加zoneNa0 北美

## 7.1.2 (2016-10-11)
## 增加
* 增加zone2
* 增加zone2 华南

## 7.1.1 (2016-09-08)
## 改变
Expand Down
87 changes: 42 additions & 45 deletions QiniuSDK/Common/QNPHAssetFile.m
100755 → 100644
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,6 @@ - (instancetype)init:(PHAsset *)phAsset error:(NSError *__autoreleasing *)error
_file = f;
_assetData = d;
}

}
return self;
}
Expand All @@ -97,10 +96,8 @@ - (void)close {
if (PHAssetMediaTypeVideo == self.phAsset.mediaType) {
if (_file != nil) {
[_file closeFile];

}
[[NSFileManager defaultManager] removeItemAtPath: _filepath error: nil];

[[NSFileManager defaultManager] removeItemAtPath:_filepath error:nil];
}
}

Expand All @@ -117,50 +114,50 @@ - (int64_t)size {
}

- (NSString *)getInfo {
__block NSString * filePath = nil;
__block NSString *filePath = nil;
if (PHAssetMediaTypeImage == self.phAsset.mediaType) {
PHImageRequestOptions *options = [PHImageRequestOptions new];
options.version = PHImageRequestOptionsVersionCurrent;
options.deliveryMode = PHImageRequestOptionsDeliveryModeHighQualityFormat;
options.resizeMode = PHImageRequestOptionsResizeModeNone;
//不支持icloud上传
options.networkAccessAllowed = NO;
options.synchronous = YES;

[[PHImageManager defaultManager] requestImageDataForAsset:self.phAsset
options:options
resultHandler:^(NSData *imageData, NSString *dataUTI, UIImageOrientation orientation, NSDictionary *info) {
_assetData = imageData;
_fileSize = imageData.length;
_assetURL = [NSURL URLWithString:self.phAsset.localIdentifier];
filePath = _assetURL.path;
}];
} else if (PHAssetMediaTypeVideo == self.phAsset.mediaType) {
NSArray * assetResources = [PHAssetResource assetResourcesForAsset: self.phAsset];
PHAssetResource * resource;
for (PHAssetResource * assetRes in assetResources) {
if (assetRes.type == PHAssetResourceTypePairedVideo || assetRes.type == PHAssetResourceTypeVideo) {
resource = assetRes;
}
PHImageRequestOptions *options = [PHImageRequestOptions new];
options.version = PHImageRequestOptionsVersionCurrent;
options.deliveryMode = PHImageRequestOptionsDeliveryModeHighQualityFormat;
options.resizeMode = PHImageRequestOptionsResizeModeNone;
//不支持icloud上传
options.networkAccessAllowed = NO;
options.synchronous = YES;

[[PHImageManager defaultManager] requestImageDataForAsset:self.phAsset
options:options
resultHandler:^(NSData *imageData, NSString *dataUTI, UIImageOrientation orientation, NSDictionary *info) {
_assetData = imageData;
_fileSize = imageData.length;
_assetURL = [NSURL URLWithString:self.phAsset.localIdentifier];
filePath = _assetURL.path;
}];
} else if (PHAssetMediaTypeVideo == self.phAsset.mediaType) {
NSArray *assetResources = [PHAssetResource assetResourcesForAsset:self.phAsset];
PHAssetResource *resource;
for (PHAssetResource *assetRes in assetResources) {
if (assetRes.type == PHAssetResourceTypePairedVideo || assetRes.type == PHAssetResourceTypeVideo) {
resource = assetRes;
}
NSString * fileName = @"tempAssetVideo.mov";
if (resource.originalFilename) {
fileName = resource.originalFilename;
}
NSString *fileName = @"tempAssetVideo.mov";
if (resource.originalFilename) {
fileName = resource.originalFilename;
}
PHVideoRequestOptions *options = [[PHVideoRequestOptions alloc] init];
options.version = PHImageRequestOptionsVersionCurrent;
//不支持icloud上传
options.networkAccessAllowed = NO;
options.deliveryMode = PHVideoRequestOptionsDeliveryModeAutomatic;
NSString *PATH_VIDEO_FILE = [NSTemporaryDirectory() stringByAppendingPathComponent:fileName];
[[NSFileManager defaultManager] removeItemAtPath:PATH_VIDEO_FILE error:nil];
[[PHAssetResourceManager defaultManager] writeDataForAssetResource:resource toFile:[NSURL fileURLWithPath:PATH_VIDEO_FILE] options:options completionHandler:^(NSError *_Nullable error) {
if (error) {
filePath = nil;
} else {
filePath = PATH_VIDEO_FILE;
}
PHVideoRequestOptions * options = [[PHVideoRequestOptions alloc] init];
options.version = PHImageRequestOptionsVersionCurrent;
//不支持icloud上传
options.networkAccessAllowed = NO;
options.deliveryMode = PHVideoRequestOptionsDeliveryModeAutomatic;
NSString * PATH_VIDEO_FILE = [NSTemporaryDirectory() stringByAppendingPathComponent: fileName];
[[NSFileManager defaultManager] removeItemAtPath: PATH_VIDEO_FILE error: nil];
[[PHAssetResourceManager defaultManager] writeDataForAssetResource: resource toFile: [NSURL fileURLWithPath: PATH_VIDEO_FILE] options: options completionHandler: ^(NSError * _Nullable error) {
if (error) {
filePath = nil;
} else {
filePath = PATH_VIDEO_FILE;
}
}];
}];
}
return filePath;
}
Expand Down
2 changes: 1 addition & 1 deletion QiniuSDK/Common/QNVersion.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,4 @@
/**
* sdk 版本
*/
static const NSString *kQiniuVersion = @"7.1.2";
static const NSString *kQiniuVersion = @"7.1.3";
4 changes: 2 additions & 2 deletions QiniuSDK/Http/QNSessionManager.h
100755 → 100644
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@
withCancelBlock:(QNCancelBlock)cancelBlock;

- (void)get:(NSString *)url
withHeaders:(NSDictionary *)headers
withCompleteBlock:(QNCompleteBlock)completeBlock;
withHeaders:(NSDictionary *)headers
withCompleteBlock:(QNCompleteBlock)completeBlock;

@end

Expand Down
14 changes: 7 additions & 7 deletions QiniuSDK/Http/QNSessionManager.m
Original file line number Diff line number Diff line change
Expand Up @@ -308,20 +308,20 @@ - (void)post:(NSString *)url
}

- (void)get:(NSString *)url
withHeaders:(NSDictionary *)headers
withCompleteBlock:(QNCompleteBlock)completeBlock {
withHeaders:(NSDictionary *)headers
withCompleteBlock:(QNCompleteBlock)completeBlock {
QNAsyncRun(^{
NSURLSessionConfiguration *configuration = [NSURLSessionConfiguration defaultSessionConfiguration];
AFURLSessionManager *manager = [[AFURLSessionManager alloc] initWithSessionConfiguration:configuration];

NSURL *URL = [NSURL URLWithString:url];
NSURLRequest *request = [NSURLRequest requestWithURL:URL];

NSURLSessionDataTask *dataTask = [manager dataTaskWithRequest:request completionHandler:^(NSURLResponse *response, id responseObject, NSError *error) {
NSHTTPURLResponse *httpResponse = (NSHTTPURLResponse *)response;
NSData* s = [@"{}" dataUsingEncoding:NSUTF8StringEncoding];
NSData *s = [@"{}" dataUsingEncoding:NSUTF8StringEncoding];
NSDictionary *resp = nil;
QNResponseInfo* info;
QNResponseInfo *info;
if (error == nil) {
info = [QNSessionManager buildResponseInfo:httpResponse withError:nil withDuration:0 withResponse:s withHost:@"" withIp:@""];
if (info.isOK) {
Expand All @@ -330,7 +330,7 @@ - (void)get:(NSString *)url
} else {
info = [QNSessionManager buildResponseInfo:httpResponse withError:error withDuration:0 withResponse:s withHost:@"" withIp:@""];
}

completeBlock(info, resp);
}];
[dataTask resume];
Expand Down
24 changes: 15 additions & 9 deletions QiniuSDK/Storage/QNConfiguration.h
100755 → 100644
Original file line number Diff line number Diff line change
Expand Up @@ -99,38 +99,45 @@ typedef void (^QNPrequeryReturn)(int code);
/**
* 默认上传服务器地址
*/
- (QNServiceAddress *)up:(QNUpToken*)token;
- (QNServiceAddress *)up:(QNUpToken *)token;

/**
* 备用上传服务器地址
*/
- (QNServiceAddress *)upBackup:(QNUpToken*)token;
- (QNServiceAddress *)upBackup:(QNUpToken *)token;

/**
* zone 0
* zone 0 华东
*
* @return 实例
*/
+ (instancetype)zone0;

/**
* zone 1
* zone 1 华北
*
* @return 实例
*/
+ (instancetype)zone1;

/**
* zone 2
* zone 2 华南
*
* @return 实例
*/
+ (instancetype)zone2;

- (void)preQuery:(QNUpToken*)token
/**
* zone Na0 北美
*
* @return 实例
*/
+ (instancetype)zoneNa0;

- (void)preQuery:(QNUpToken *)token
on:(QNPrequeryReturn)ret;

+ (void)addIpToDns:(QNDnsManager*)dns;
+ (void)addIpToDns:(QNDnsManager *)dns;

@end

Expand All @@ -152,8 +159,7 @@ typedef void (^QNPrequeryReturn)(int code);
@interface QNAutoZone : QNZone

- (instancetype)initWithHttps:(BOOL)flag
dns:(QNDnsManager*)dns;

dns:(QNDnsManager *)dns;

@end

Expand Down
Loading

0 comments on commit b5734ed

Please sign in to comment.