Commit f6ce3576 authored by 曹云霄's avatar 曹云霄

更新NSDate 时间格式化方法

parent 5a60dbcd
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
objects = { objects = {
/* Begin PBXBuildFile section */ /* Begin PBXBuildFile section */
1937CACFAD7A14F1E3DF81BC /* libPods-Lighting_base-Lighting.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 45832B4C5897A090FD0C67E7 /* libPods-Lighting_base-Lighting.a */; }; 288998AFBE1F81DC7C55CB20 /* libPods-Lighting_base-LightingDis.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 9778A87FC0ABB532F6D97195 /* libPods-Lighting_base-LightingDis.a */; };
29ACE2D01F14BB9200BE8DB0 /* AnnouncementContentTableViewCell.m in Sources */ = {isa = PBXBuildFile; fileRef = 29ACDFE61F14BB9000BE8DB0 /* AnnouncementContentTableViewCell.m */; }; 29ACE2D01F14BB9200BE8DB0 /* AnnouncementContentTableViewCell.m in Sources */ = {isa = PBXBuildFile; fileRef = 29ACDFE61F14BB9000BE8DB0 /* AnnouncementContentTableViewCell.m */; };
29ACE2D11F14BB9200BE8DB0 /* AnnouncementContentTableViewCell.m in Sources */ = {isa = PBXBuildFile; fileRef = 29ACDFE61F14BB9000BE8DB0 /* AnnouncementContentTableViewCell.m */; }; 29ACE2D11F14BB9200BE8DB0 /* AnnouncementContentTableViewCell.m in Sources */ = {isa = PBXBuildFile; fileRef = 29ACDFE61F14BB9000BE8DB0 /* AnnouncementContentTableViewCell.m */; };
29ACE2D21F14BB9200BE8DB0 /* AnnouncementContentTableViewCell.m in Sources */ = {isa = PBXBuildFile; fileRef = 29ACDFE61F14BB9000BE8DB0 /* AnnouncementContentTableViewCell.m */; }; 29ACE2D21F14BB9200BE8DB0 /* AnnouncementContentTableViewCell.m in Sources */ = {isa = PBXBuildFile; fileRef = 29ACDFE61F14BB9000BE8DB0 /* AnnouncementContentTableViewCell.m */; };
...@@ -962,8 +962,10 @@ ...@@ -962,8 +962,10 @@
29ACED4A1F15C94E00BE8DB0 /* BasePullTableViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 29ACED491F15C94E00BE8DB0 /* BasePullTableViewController.m */; }; 29ACED4A1F15C94E00BE8DB0 /* BasePullTableViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 29ACED491F15C94E00BE8DB0 /* BasePullTableViewController.m */; };
29ACED4B1F15C94E00BE8DB0 /* BasePullTableViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 29ACED491F15C94E00BE8DB0 /* BasePullTableViewController.m */; }; 29ACED4B1F15C94E00BE8DB0 /* BasePullTableViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 29ACED491F15C94E00BE8DB0 /* BasePullTableViewController.m */; };
29ACED4C1F15C94E00BE8DB0 /* BasePullTableViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 29ACED491F15C94E00BE8DB0 /* BasePullTableViewController.m */; }; 29ACED4C1F15C94E00BE8DB0 /* BasePullTableViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 29ACED491F15C94E00BE8DB0 /* BasePullTableViewController.m */; };
92E1C4040997A426033BDE2B /* libPods-Lighting_base-LightingDis.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 9778A87FC0ABB532F6D97195 /* libPods-Lighting_base-LightingDis.a */; }; 29E44CFC1F186E41002CE079 /* libPods-Lighting_base-LightingDis.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 29E44CFB1F186E41002CE079 /* libPods-Lighting_base-LightingDis.a */; };
B57F1312C86445E343E21E49 /* libPods-Lighting_base-LightingDev.a in Frameworks */ = {isa = PBXBuildFile; fileRef = D7A866AAC01D49CEAECE5D3B /* libPods-Lighting_base-LightingDev.a */; }; 29E44CFF1F186E83002CE079 /* libPods-Lighting_base-Lighting.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 29E44CFE1F186E83002CE079 /* libPods-Lighting_base-Lighting.a */; };
2C3A12B1657983F23BAE2A5D /* libPods-Lighting_base-Lighting.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 45832B4C5897A090FD0C67E7 /* libPods-Lighting_base-Lighting.a */; };
38073AB33AB0A15312BD17DA /* libPods-Lighting_base-LightingDev.a in Frameworks */ = {isa = PBXBuildFile; fileRef = D7A866AAC01D49CEAECE5D3B /* libPods-Lighting_base-LightingDev.a */; };
/* End PBXBuildFile section */ /* End PBXBuildFile section */
/* Begin PBXFileReference section */ /* Begin PBXFileReference section */
...@@ -1577,6 +1579,9 @@ ...@@ -1577,6 +1579,9 @@
29ACED3A1F14CA4300BE8DB0 /* loadingImage.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = loadingImage.png; sourceTree = "<group>"; }; 29ACED3A1F14CA4300BE8DB0 /* loadingImage.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = loadingImage.png; sourceTree = "<group>"; };
29ACED481F15C94E00BE8DB0 /* BasePullTableViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = BasePullTableViewController.h; sourceTree = "<group>"; }; 29ACED481F15C94E00BE8DB0 /* BasePullTableViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = BasePullTableViewController.h; sourceTree = "<group>"; };
29ACED491F15C94E00BE8DB0 /* BasePullTableViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = BasePullTableViewController.m; sourceTree = "<group>"; }; 29ACED491F15C94E00BE8DB0 /* BasePullTableViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = BasePullTableViewController.m; sourceTree = "<group>"; };
29E44CFB1F186E41002CE079 /* libPods-Lighting_base-LightingDis.a */ = {isa = PBXFileReference; lastKnownFileType = archive.ar; name = "libPods-Lighting_base-LightingDis.a"; path = "Pods/../build/Debug-iphoneos/libPods-Lighting_base-LightingDis.a"; sourceTree = "<group>"; };
29E44CFD1F186E7E002CE079 /* libPods-Lighting_base-LightingDev.a */ = {isa = PBXFileReference; lastKnownFileType = archive.ar; name = "libPods-Lighting_base-LightingDev.a"; path = "Pods/../build/Debug-iphoneos/libPods-Lighting_base-LightingDev.a"; sourceTree = "<group>"; };
29E44CFE1F186E83002CE079 /* libPods-Lighting_base-Lighting.a */ = {isa = PBXFileReference; lastKnownFileType = archive.ar; name = "libPods-Lighting_base-Lighting.a"; path = "../../Library/Developer/Xcode/DerivedData/Lighting-gwtabmajswyhchcvtqfwfndypgrd/Build/Products/Debug-iphonesimulator/libPods-Lighting_base-Lighting.a"; sourceTree = "<group>"; };
3358C8B7E1E6A321BC93C189 /* Pods-Lighting_base-LightingDis.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Lighting_base-LightingDis.release.xcconfig"; path = "Pods/Target Support Files/Pods-Lighting_base-LightingDis/Pods-Lighting_base-LightingDis.release.xcconfig"; sourceTree = "<group>"; }; 3358C8B7E1E6A321BC93C189 /* Pods-Lighting_base-LightingDis.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Lighting_base-LightingDis.release.xcconfig"; path = "Pods/Target Support Files/Pods-Lighting_base-LightingDis/Pods-Lighting_base-LightingDis.release.xcconfig"; sourceTree = "<group>"; };
3A6B1B971D67567942058456 /* Pods-Lighting_base-Lighting.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Lighting_base-Lighting.release.xcconfig"; path = "Pods/Target Support Files/Pods-Lighting_base-Lighting/Pods-Lighting_base-Lighting.release.xcconfig"; sourceTree = "<group>"; }; 3A6B1B971D67567942058456 /* Pods-Lighting_base-Lighting.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Lighting_base-Lighting.release.xcconfig"; path = "Pods/Target Support Files/Pods-Lighting_base-Lighting/Pods-Lighting_base-Lighting.release.xcconfig"; sourceTree = "<group>"; };
45832B4C5897A090FD0C67E7 /* libPods-Lighting_base-Lighting.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = "libPods-Lighting_base-Lighting.a"; sourceTree = BUILT_PRODUCTS_DIR; }; 45832B4C5897A090FD0C67E7 /* libPods-Lighting_base-Lighting.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = "libPods-Lighting_base-Lighting.a"; sourceTree = BUILT_PRODUCTS_DIR; };
...@@ -1591,7 +1596,7 @@ ...@@ -1591,7 +1596,7 @@
isa = PBXFrameworksBuildPhase; isa = PBXFrameworksBuildPhase;
buildActionMask = 2147483647; buildActionMask = 2147483647;
files = ( files = (
B57F1312C86445E343E21E49 /* libPods-Lighting_base-LightingDev.a in Frameworks */, 38073AB33AB0A15312BD17DA /* libPods-Lighting_base-LightingDev.a in Frameworks */,
); );
runOnlyForDeploymentPostprocessing = 0; runOnlyForDeploymentPostprocessing = 0;
}; };
...@@ -1599,7 +1604,8 @@ ...@@ -1599,7 +1604,8 @@
isa = PBXFrameworksBuildPhase; isa = PBXFrameworksBuildPhase;
buildActionMask = 2147483647; buildActionMask = 2147483647;
files = ( files = (
92E1C4040997A426033BDE2B /* libPods-Lighting_base-LightingDis.a in Frameworks */, 29E44CFC1F186E41002CE079 /* libPods-Lighting_base-LightingDis.a in Frameworks */,
288998AFBE1F81DC7C55CB20 /* libPods-Lighting_base-LightingDis.a in Frameworks */,
); );
runOnlyForDeploymentPostprocessing = 0; runOnlyForDeploymentPostprocessing = 0;
}; };
...@@ -1607,7 +1613,8 @@ ...@@ -1607,7 +1613,8 @@
isa = PBXFrameworksBuildPhase; isa = PBXFrameworksBuildPhase;
buildActionMask = 2147483647; buildActionMask = 2147483647;
files = ( files = (
1937CACFAD7A14F1E3DF81BC /* libPods-Lighting_base-Lighting.a in Frameworks */, 29E44CFF1F186E83002CE079 /* libPods-Lighting_base-Lighting.a in Frameworks */,
2C3A12B1657983F23BAE2A5D /* libPods-Lighting_base-Lighting.a in Frameworks */,
); );
runOnlyForDeploymentPostprocessing = 0; runOnlyForDeploymentPostprocessing = 0;
}; };
...@@ -1617,6 +1624,9 @@ ...@@ -1617,6 +1624,9 @@
0506605DC12BE57F779D6619 /* Frameworks */ = { 0506605DC12BE57F779D6619 /* Frameworks */ = {
isa = PBXGroup; isa = PBXGroup;
children = ( children = (
29E44CFE1F186E83002CE079 /* libPods-Lighting_base-Lighting.a */,
29E44CFD1F186E7E002CE079 /* libPods-Lighting_base-LightingDev.a */,
29E44CFB1F186E41002CE079 /* libPods-Lighting_base-LightingDis.a */,
45832B4C5897A090FD0C67E7 /* libPods-Lighting_base-Lighting.a */, 45832B4C5897A090FD0C67E7 /* libPods-Lighting_base-Lighting.a */,
D7A866AAC01D49CEAECE5D3B /* libPods-Lighting_base-LightingDev.a */, D7A866AAC01D49CEAECE5D3B /* libPods-Lighting_base-LightingDev.a */,
9778A87FC0ABB532F6D97195 /* libPods-Lighting_base-LightingDis.a */, 9778A87FC0ABB532F6D97195 /* libPods-Lighting_base-LightingDis.a */,
...@@ -4964,7 +4974,10 @@ ...@@ -4964,7 +4974,10 @@
INFOPLIST_FILE = "$(SRCROOT)/Lighting/Supporting Files/LightingDis-Info.plist"; INFOPLIST_FILE = "$(SRCROOT)/Lighting/Supporting Files/LightingDis-Info.plist";
IPHONEOS_DEPLOYMENT_TARGET = 9.0; IPHONEOS_DEPLOYMENT_TARGET = 9.0;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
LIBRARY_SEARCH_PATHS = "$(inherited)"; LIBRARY_SEARCH_PATHS = (
"$(inherited)",
"$(PROJECT_DIR)/build/Debug-iphoneos",
);
ONLY_ACTIVE_ARCH = YES; ONLY_ACTIVE_ARCH = YES;
OTHER_LDFLAGS = ( OTHER_LDFLAGS = (
"$(inherited)", "$(inherited)",
...@@ -5039,7 +5052,10 @@ ...@@ -5039,7 +5052,10 @@
INFOPLIST_FILE = "$(SRCROOT)/Lighting/Supporting Files/LightingDis-Info.plist"; INFOPLIST_FILE = "$(SRCROOT)/Lighting/Supporting Files/LightingDis-Info.plist";
IPHONEOS_DEPLOYMENT_TARGET = 9.0; IPHONEOS_DEPLOYMENT_TARGET = 9.0;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
LIBRARY_SEARCH_PATHS = "$(inherited)"; LIBRARY_SEARCH_PATHS = (
"$(inherited)",
"$(PROJECT_DIR)/build/Debug-iphoneos",
);
ONLY_ACTIVE_ARCH = NO; ONLY_ACTIVE_ARCH = NO;
OTHER_LDFLAGS = ( OTHER_LDFLAGS = (
"$(inherited)", "$(inherited)",
......
...@@ -101,7 +101,6 @@ ...@@ -101,7 +101,6 @@
WS(weakSelf); WS(weakSelf);
[XBLoadingView showHUDViewWithDefault];; [XBLoadingView showHUDViewWithDefault];;
[HTTP networkWithDictionaryRequestWithURL:[NSString stringWithFormat:SERVERREQUESTURL(AFFICHEdETAILS),self.announcementEntity.fid] withRequestType:ONE withParameter:nil withReturnValueBlock:^(id returnValue) { [HTTP networkWithDictionaryRequestWithURL:[NSString stringWithFormat:SERVERREQUESTURL(AFFICHEdETAILS),self.announcementEntity.fid] withRequestType:ONE withParameter:nil withReturnValueBlock:^(id returnValue) {
[XBLoadingView hideHUDViewWithDefault]; [XBLoadingView hideHUDViewWithDefault];
if (RESULT(returnValue)) { if (RESULT(returnValue)) {
weakSelf.afficheResult = [[CustomTOAfficheEntity alloc]initWithDictionary:RESPONSE(returnValue) error:nil]; weakSelf.afficheResult = [[CustomTOAfficheEntity alloc]initWithDictionary:RESPONSE(returnValue) error:nil];
...@@ -125,10 +124,9 @@ ...@@ -125,10 +124,9 @@
- (void)announcementRead - (void)announcementRead
{ {
WS(weakSelf); WS(weakSelf);
NSString *url = [NSString stringWithFormat:SERVERREQUESTURL(READANNOUNCEMENT),self.announcementEntity.fid,[Shoppersmanager manager].shoppers.employee.departid,[Shoppersmanager manager].shoppers.employee.fid,[[NSDate date] ymdHmsFormat]]; NSString *url = [NSString stringWithFormat:SERVERREQUESTURL(READANNOUNCEMENT),self.announcementEntity.fid,[Shoppersmanager manager].shoppers.employee.departid,[Shoppersmanager manager].shoppers.employee.fid,[[NSDate date] httpParameterString]];
url = [url stringByAddingPercentEncodingWithAllowedCharacters:[NSCharacterSet characterSetWithCharactersInString:@"`#%^{}\"[]|\\<> "].invertedSet]; url = [url stringByAddingPercentEncodingWithAllowedCharacters:[NSCharacterSet characterSetWithCharactersInString:@"`#%^{}\"[]|\\<> "].invertedSet];
[HTTP networkWithDictionaryRequestWithURL:url withRequestType:ZERO withParameter:nil withReturnValueBlock:^(id returnValue) { [HTTP networkWithDictionaryRequestWithURL:url withRequestType:ZERO withParameter:nil withReturnValueBlock:^(id returnValue) {
if (RESULT(returnValue)) { if (RESULT(returnValue)) {
if (weakSelf.readBlock) { if (weakSelf.readBlock) {
weakSelf.readBlock(); weakSelf.readBlock();
......
...@@ -161,7 +161,7 @@ ...@@ -161,7 +161,7 @@
TOStudyResultEntity *studyResult = self.studyResult; TOStudyResultEntity *studyResult = self.studyResult;
// studyResult.taskId = self.taskId; // studyResult.taskId = self.taskId;
// studyResult.employeeId = [Shoppersmanager manager].shoppers.employee.fid; // studyResult.employeeId = [Shoppersmanager manager].shoppers.employee.fid;
studyResult.submitTime = [[NSDate date] ymdHmsFormat]; studyResult.submitTime = [[NSDate date] httpParameterString];
NSArray *answerArray = self.taskDetails.topics; NSArray *answerArray = self.taskDetails.topics;
NSMutableArray *submitAnswerArray = [NSMutableArray array]; NSMutableArray *submitAnswerArray = [NSMutableArray array];
NSInteger allScore = 0;//总分 NSInteger allScore = 0;//总分
......
...@@ -49,7 +49,7 @@ ...@@ -49,7 +49,7 @@
ToStoreAddress *address = [[ToStoreAddress alloc] init]; ToStoreAddress *address = [[ToStoreAddress alloc] init];
address.resellerid = [Shoppersmanager manager].shoppers.employee.currentDepart.fid; address.resellerid = [Shoppersmanager manager].shoppers.employee.currentDepart.fid;
address.storecode = [Shoppersmanager manager].shoppers.storeCode; address.storecode = [Shoppersmanager manager].shoppers.storeCode;
address.createDate = [[NSDate date] ymdHmsFormat]; address.createDate = [[NSDate date] httpParameterString];
address.province = addressArray[0]; address.province = addressArray[0];
address.city = addressArray[1]; address.city = addressArray[1];
address.country = addressArray[2]; address.country = addressArray[2];
......
...@@ -418,14 +418,11 @@ ...@@ -418,14 +418,11 @@
- (void)detectionUpdateVersion - (void)detectionUpdateVersion
{ {
[XBLoadingView hideHUDViewWithDefault]; [XBLoadingView hideHUDViewWithDefault];
NSString *path = [[NSBundle mainBundle]pathForResource:@"Info" ofType:@"plist"]; NSString *version = [[[NSBundle mainBundle] infoDictionary] objectForKey:@"CFBundleShortVersionString"];
NSDictionary* content =[NSDictionary dictionaryWithContentsOfFile:path];
NSString *version = [content valueForKey:@"CFBundleShortVersionString"];
//获取服务端版本大小 //获取服务端版本大小
WS(weakSelf); WS(weakSelf);
NSString *string = [NSString stringWithFormat:@"/employee/getUpgrade?apptype=IOS&version=%@",version]; NSString *string = [NSString stringWithFormat:@"/employee/getUpgrade?apptype=ipa&version=%@",version];
[HTTP networkWithDictionaryRequestWithURL:SERVERREQUESTURL(string) withRequestType:ONE withParameter:nil withReturnValueBlock:^(id returnValue) { [HTTP networkWithDictionaryRequestWithURL:SERVERREQUESTURL(string) withRequestType:ONE withParameter:nil withReturnValueBlock:^(id returnValue) {
if (RESULT(returnValue)) { if (RESULT(returnValue)) {
NSDictionary *dict = RESPONSE(returnValue); NSDictionary *dict = RESPONSE(returnValue);
if (!dict || [dict isKindOfClass:[NSNull class]]) { if (!dict || [dict isKindOfClass:[NSNull class]]) {
......
...@@ -57,7 +57,7 @@ ...@@ -57,7 +57,7 @@
[XBLoadingView showHUDViewWithDefault]; [XBLoadingView showHUDViewWithDefault];
WS(weakSelf); WS(weakSelf);
TOResellerstoreEntity *entity = [[TOResellerstoreEntity alloc] init]; TOResellerstoreEntity *entity = [[TOResellerstoreEntity alloc] init];
entity.createDate = [[NSDate date] ymdHmsFormat]; entity.createDate = [[NSDate date] httpParameterString];
entity.storecode = storeCode; entity.storecode = storeCode;
entity.resellerid = [Shoppersmanager manager].shoppers.employee.currentDepart.fid; entity.resellerid = [Shoppersmanager manager].shoppers.employee.currentDepart.fid;
[HTTP networkRequestWithURL:SERVERREQUESTURL(SAVERESELLER) withRequestType:POST withParameter:entity withReturnValueBlock:^(id returnValue) { [HTTP networkRequestWithURL:SERVERREQUESTURL(SAVERESELLER) withRequestType:POST withParameter:entity withReturnValueBlock:^(id returnValue) {
......
...@@ -330,7 +330,7 @@ ...@@ -330,7 +330,7 @@
if (model.isSelected) { if (model.isSelected) {
//收货人信息 //收货人信息
orderReceiver.receiverName = model.name; orderReceiver.receiverName = model.name;
orderReceiver.orderTime = [[NSDate date] ymdHmsFormat]; orderReceiver.orderTime = [[NSDate date] httpParameterString];
orderReceiver.receiverMobile = model.miblephone; orderReceiver.receiverMobile = model.miblephone;
orderReceiver.receiverAddress = model.address; orderReceiver.receiverAddress = model.address;
order.order = orderReceiver; order.order = orderReceiver;
......
...@@ -60,7 +60,7 @@ static OSSClient *client; ...@@ -60,7 +60,7 @@ static OSSClient *client;
{ {
OSSPutObjectRequest * put = [OSSPutObjectRequest new]; OSSPutObjectRequest * put = [OSSPutObjectRequest new];
put.bucketName = bucketName; put.bucketName = bucketName;
put.objectKey = [NSString stringWithFormat:@"%@%@/%@",OSSImagePath,[[NSDate date] ymdFormat],ObjectKey]; put.objectKey = [NSString stringWithFormat:@"%@%@/%@",OSSImagePath,[[NSDate date] yearMonthDayString],ObjectKey];
//判断文件在OSS是否存在 //判断文件在OSS是否存在
if ([client doesObjectExistInBucket:put.bucketName objectKey:ObjectKey error:nil]) { if ([client doesObjectExistInBucket:put.bucketName objectKey:ObjectKey error:nil]) {
success([OSSTask new]); success([OSSTask new]);
...@@ -97,7 +97,7 @@ static OSSClient *client; ...@@ -97,7 +97,7 @@ static OSSClient *client;
{ {
OSSPutObjectRequest * put = [OSSPutObjectRequest new]; OSSPutObjectRequest * put = [OSSPutObjectRequest new];
put.bucketName = bucketName; put.bucketName = bucketName;
put.objectKey = [NSString stringWithFormat:@"%@%@/%@",OSSVideoPath,[[NSDate date] ymdFormat],ObjectKey]; put.objectKey = [NSString stringWithFormat:@"%@%@/%@",OSSVideoPath,[[NSDate date] yearMonthDayString],ObjectKey];
//判断文件在OSS是否存在 //判断文件在OSS是否存在
if ([client doesObjectExistInBucket:put.bucketName objectKey:ObjectKey error:nil]) { if ([client doesObjectExistInBucket:put.bucketName objectKey:ObjectKey error:nil]) {
success([OSSTask new]); success([OSSTask new]);
...@@ -256,7 +256,7 @@ static OSSClient *client; ...@@ -256,7 +256,7 @@ static OSSClient *client;
+ (NSString *)getCompleteImageURLWithOSSkey:(NSString *)OSSKey + (NSString *)getCompleteImageURLWithOSSkey:(NSString *)OSSKey
{ {
NSArray *ossStringArray = [endPoint componentsSeparatedByString:@"//"]; NSArray *ossStringArray = [endPoint componentsSeparatedByString:@"//"];
return [NSString stringWithFormat:@"http://%@.%@/%@%@/%@",bucketName,[ossStringArray lastObject],OSSImagePath,[[NSDate date] ymdFormat],OSSKey]; return [NSString stringWithFormat:@"http://%@.%@/%@%@/%@",bucketName,[ossStringArray lastObject],OSSImagePath,[[NSDate date] yearMonthDayString],OSSKey];
} }
/** /**
...@@ -269,7 +269,7 @@ static OSSClient *client; ...@@ -269,7 +269,7 @@ static OSSClient *client;
+ (NSString *)getCompleteVideoURLWithOSSkey:(NSString *)OSSKey + (NSString *)getCompleteVideoURLWithOSSkey:(NSString *)OSSKey
{ {
NSArray *ossStringArray = [endPoint componentsSeparatedByString:@"//"]; NSArray *ossStringArray = [endPoint componentsSeparatedByString:@"//"];
return [NSString stringWithFormat:@"http://%@.%@/%@%@/%@",bucketName,[ossStringArray lastObject],OSSVideoPath,[[NSDate date] ymdFormat],OSSKey]; return [NSString stringWithFormat:@"http://%@.%@/%@%@/%@",bucketName,[ossStringArray lastObject],OSSVideoPath,[[NSDate date] yearMonthDayString],OSSKey];
} }
......
...@@ -14,7 +14,7 @@ PODS: ...@@ -14,7 +14,7 @@ PODS:
- AFNetworking/Serialization (3.1.0) - AFNetworking/Serialization (3.1.0)
- AFNetworking/UIKit (3.1.0): - AFNetworking/UIKit (3.1.0):
- AFNetworking/NSURLSession - AFNetworking/NSURLSession
- AliyunOSSiOS (2.6.0) - AliyunOSSiOS (2.6.1)
- Bugly (2.4.8) - Bugly (2.4.8)
- DACircularProgress (2.3.1) - DACircularProgress (2.3.1)
- DZNEmptyDataSet (1.8.1) - DZNEmptyDataSet (1.8.1)
...@@ -62,7 +62,7 @@ PODS: ...@@ -62,7 +62,7 @@ PODS:
- WYPopoverController (0.3.9) - WYPopoverController (0.3.9)
- WZLBadge (1.2.6) - WZLBadge (1.2.6)
- YXAlertController (1.0.7) - YXAlertController (1.0.7)
- YXKit (0.0.2) - YXKit (0.0.4)
DEPENDENCIES: DEPENDENCIES:
- AFNetworking (~> 3.1.0) - AFNetworking (~> 3.1.0)
...@@ -88,11 +88,11 @@ DEPENDENCIES: ...@@ -88,11 +88,11 @@ DEPENDENCIES:
- WYPopoverController (~> 0.3.9) - WYPopoverController (~> 0.3.9)
- WZLBadge (~> 1.2.5) - WZLBadge (~> 1.2.5)
- YXAlertController (~> 1.0.7) - YXAlertController (~> 1.0.7)
- YXKit (~> 0.0.2) - YXKit (~> 0.0.4)
SPEC CHECKSUMS: SPEC CHECKSUMS:
AFNetworking: 5e0e199f73d8626b11e79750991f5d173d1f8b67 AFNetworking: 5e0e199f73d8626b11e79750991f5d173d1f8b67
AliyunOSSiOS: '058b038cc82000dadb8f8e3893a97243124f2898' AliyunOSSiOS: 8174b695e09b136afe43a6af821c3ca71d423373
Bugly: da3c02408c14838d498429320545a8e439392978 Bugly: da3c02408c14838d498429320545a8e439392978
DACircularProgress: 4dd437c0fc3da5161cb289e07ac449493d41db71 DACircularProgress: 4dd437c0fc3da5161cb289e07ac449493d41db71
DZNEmptyDataSet: 9525833b9e68ac21c30253e1d3d7076cc828eaa7 DZNEmptyDataSet: 9525833b9e68ac21c30253e1d3d7076cc828eaa7
...@@ -116,8 +116,8 @@ SPEC CHECKSUMS: ...@@ -116,8 +116,8 @@ SPEC CHECKSUMS:
WYPopoverController: a9db25ac2841a686acdc0f3a99bdb21545db32f4 WYPopoverController: a9db25ac2841a686acdc0f3a99bdb21545db32f4
WZLBadge: 9ec779dcfd94c825518b395e8315fccaabff1bfa WZLBadge: 9ec779dcfd94c825518b395e8315fccaabff1bfa
YXAlertController: 68e27c48976fa9ecc0b82e63166b67863be8b70b YXAlertController: 68e27c48976fa9ecc0b82e63166b67863be8b70b
YXKit: 4869008392fd3ee0290ccc4dd657859b8a2e5939 YXKit: ed7714bc185dde43b1a5d1c4f7df760d9b2ec7f7
PODFILE CHECKSUM: 21f6d460b0f56a2bde65ba0bf298c5a07eacf877 PODFILE CHECKSUM: 962a8b96654703335e32ffd05a5bd7c50c577ac2
COCOAPODS: 1.2.1 COCOAPODS: 1.2.1
...@@ -215,6 +215,18 @@ NS_ASSUME_NONNULL_BEGIN ...@@ -215,6 +215,18 @@ NS_ASSUME_NONNULL_BEGIN
withObjectKey:(NSString *)objectKey withObjectKey:(NSString *)objectKey
withExpirationInterval:(NSTimeInterval)interval; withExpirationInterval:(NSTimeInterval)interval;
/**
对一个Object签名出一个URL,可以把该URL转给第三方实现授权访问。
@bucketName Object所在的Bucket名称
@objectKey Object名称
@interval 签名URL时,可以指定这个URL的有效时长是多久,单位是秒,比如说需要有效时长为1小时的URL,这里传入3600
@parameter 参数
*/
- (OSSTask *)presignConstrainURLWithBucketName:(NSString *)bucketName
withObjectKey:(NSString *)objectKey
withExpirationInterval:(NSTimeInterval)interval
withParameters:(NSDictionary *)parameters;
/** /**
如果Object的权限是公共读或者公共读写,调用这个接口对该Object签名出一个URL,可以把该URL转给第三方实现授权访问。 如果Object的权限是公共读或者公共读写,调用这个接口对该Object签名出一个URL,可以把该URL转给第三方实现授权访问。
@bucketName Object所在的Bucket名称 @bucketName Object所在的Bucket名称
...@@ -223,6 +235,16 @@ NS_ASSUME_NONNULL_BEGIN ...@@ -223,6 +235,16 @@ NS_ASSUME_NONNULL_BEGIN
- (OSSTask *)presignPublicURLWithBucketName:(NSString *)bucketName - (OSSTask *)presignPublicURLWithBucketName:(NSString *)bucketName
withObjectKey:(NSString *)objectKey; withObjectKey:(NSString *)objectKey;
/**
如果Object的权限是公共读或者公共读写,调用这个接口对该Object签名出一个URL,可以把该URL转给第三方实现授权访问。
@bucketName Object所在的Bucket名称
@objectKey Object名称
@parameter 参数
*/
- (OSSTask *)presignPublicURLWithBucketName:(NSString *)bucketName
withObjectKey:(NSString *)objectKey
withParameters:(NSDictionary *)parameters;
/** /**
断点上传接口 断点上传接口
这个接口封装了分块上传的若干接口以实现断点上传,但是需要用户自行保存UploadId。 这个接口封装了分块上传的若干接口以实现断点上传,但是需要用户自行保存UploadId。
......
...@@ -558,12 +558,28 @@ ...@@ -558,12 +558,28 @@
withObjectKey:(NSString *)objectKey withObjectKey:(NSString *)objectKey
withExpirationInterval:(NSTimeInterval)interval { withExpirationInterval:(NSTimeInterval)interval {
return [self presignConstrainURLWithBucketName:bucketName
withObjectKey:objectKey
withExpirationInterval:interval
withParameters:@{}];
}
- (OSSTask *)presignConstrainURLWithBucketName:(NSString *)bucketName
withObjectKey:(NSString *)objectKey
withExpirationInterval:(NSTimeInterval)interval
withParameters:(NSDictionary *)parameters {
return [[OSSTask taskWithResult:nil] continueWithBlock:^id(OSSTask *task) { return [[OSSTask taskWithResult:nil] continueWithBlock:^id(OSSTask *task) {
NSString * resource = [NSString stringWithFormat:@"/%@/%@", bucketName, objectKey]; NSString * resource = [NSString stringWithFormat:@"/%@/%@", bucketName, objectKey];
NSString * expires = [@((int64_t)[[NSDate oss_clockSkewFixedDate] timeIntervalSince1970] + interval) stringValue]; NSString * expires = [@((int64_t)[[NSDate oss_clockSkewFixedDate] timeIntervalSince1970] + interval) stringValue];
NSString * wholeSign = nil; NSString * wholeSign = nil;
OSSFederationToken * token = nil; OSSFederationToken * token = nil;
NSError * error = nil; NSError * error = nil;
NSMutableDictionary * params = [NSMutableDictionary new];
if (parameters) {
[params addEntriesFromDictionary:parameters];
}
if ([self.credentialProvider isKindOfClass:[OSSFederationCredentialProvider class]]) { if ([self.credentialProvider isKindOfClass:[OSSFederationCredentialProvider class]]) {
token = [(OSSFederationCredentialProvider *)self.credentialProvider getToken:&error]; token = [(OSSFederationCredentialProvider *)self.credentialProvider getToken:&error];
...@@ -576,10 +592,17 @@ ...@@ -576,10 +592,17 @@
if ([self.credentialProvider isKindOfClass:[OSSFederationCredentialProvider class]] if ([self.credentialProvider isKindOfClass:[OSSFederationCredentialProvider class]]
|| [self.credentialProvider isKindOfClass:[OSSStsTokenCredentialProvider class]]) { || [self.credentialProvider isKindOfClass:[OSSStsTokenCredentialProvider class]]) {
resource = [NSString stringWithFormat:@"%@?security-token=%@", resource, token.tToken]; if (token.tToken) {
[params setObject:token.tToken forKey:@"security-token"];
}
resource = [NSString stringWithFormat:@"%@?%@", resource, [OSSUtil populateSubresourceStringFromParameter:params]];
NSString * string2sign = [NSString stringWithFormat:@"GET\n\n\n%@\n%@", expires, resource]; NSString * string2sign = [NSString stringWithFormat:@"GET\n\n\n%@\n%@", expires, resource];
wholeSign = [OSSUtil sign:string2sign withToken:token]; wholeSign = [OSSUtil sign:string2sign withToken:token];
} else { } else {
NSString * subresource = [OSSUtil populateSubresourceStringFromParameter:params];
if ([subresource length] > 0) {
resource = [NSString stringWithFormat:@"%@?%@", resource, [OSSUtil populateSubresourceStringFromParameter:params]];
}
NSString * string2sign = [NSString stringWithFormat:@"GET\n\n\n%@\n%@", expires, resource]; NSString * string2sign = [NSString stringWithFormat:@"GET\n\n\n%@\n%@", expires, resource];
wholeSign = [self.credentialProvider sign:string2sign error:&error]; wholeSign = [self.credentialProvider sign:string2sign error:&error];
if (error) { if (error) {
...@@ -602,24 +625,29 @@ ...@@ -602,24 +625,29 @@
if ([OSSUtil isOssOriginBucketHost:host]) { if ([OSSUtil isOssOriginBucketHost:host]) {
host = [NSString stringWithFormat:@"%@.%@", bucketName, host]; host = [NSString stringWithFormat:@"%@.%@", bucketName, host];
} }
NSString * stringURL = [NSString stringWithFormat:@"%@://%@/%@?OSSAccessKeyId=%@&Expires=%@&Signature=%@", [params setObject:signature forKey:@"Signature"];
[params setObject:accessKey forKey:@"OSSAccessKeyId"];
[params setObject:expires forKey:@"Expires"];
NSString * stringURL = [NSString stringWithFormat:@"%@://%@/%@?%@",
endpointURL.scheme, endpointURL.scheme,
host, host,
[OSSUtil encodeURL:objectKey], [OSSUtil encodeURL:objectKey],
[OSSUtil encodeURL:accessKey], [OSSUtil populateQueryStringFromParameter:params]];
expires,
[OSSUtil encodeURL:signature]];
if ([self.credentialProvider isKindOfClass:[OSSFederationCredentialProvider class]]
|| [self.credentialProvider isKindOfClass:[OSSStsTokenCredentialProvider class]]) {
stringURL = [NSString stringWithFormat:@"%@&security-token=%@", stringURL, [OSSUtil encodeURL:token.tToken]];
}
return [OSSTask taskWithResult:stringURL]; return [OSSTask taskWithResult:stringURL];
}]; }];
} }
- (OSSTask *)presignPublicURLWithBucketName:(NSString *)bucketName - (OSSTask *)presignPublicURLWithBucketName:(NSString *)bucketName
withObjectKey:(NSString *)objectKey { withObjectKey:(NSString *)objectKey {
return [self presignPublicURLWithBucketName:bucketName
withObjectKey:objectKey
withParameters:@{}];
}
- (OSSTask *)presignPublicURLWithBucketName:(NSString *)bucketName
withObjectKey:(NSString *)objectKey
withParameters:(NSDictionary *)parameters {
return [[OSSTask taskWithResult:nil] continueWithBlock:^id(OSSTask *task) { return [[OSSTask taskWithResult:nil] continueWithBlock:^id(OSSTask *task) {
NSURL * endpointURL = [NSURL URLWithString:self.endpoint]; NSURL * endpointURL = [NSURL URLWithString:self.endpoint];
...@@ -627,11 +655,20 @@ ...@@ -627,11 +655,20 @@
if ([OSSUtil isOssOriginBucketHost:host]) { if ([OSSUtil isOssOriginBucketHost:host]) {
host = [NSString stringWithFormat:@"%@.%@", bucketName, host]; host = [NSString stringWithFormat:@"%@.%@", bucketName, host];
} }
NSString * stringURL = [NSString stringWithFormat:@"%@://%@/%@", if ([parameters count] > 0) {
endpointURL.scheme, NSString * stringURL = [NSString stringWithFormat:@"%@://%@/%@?%@",
host, endpointURL.scheme,
[OSSUtil encodeURL:objectKey]]; host,
return [OSSTask taskWithResult:stringURL]; [OSSUtil encodeURL:objectKey],
[OSSUtil populateQueryStringFromParameter:parameters]];
return [OSSTask taskWithResult:stringURL];
} else {
NSString * stringURL = [NSString stringWithFormat:@"%@://%@/%@",
endpointURL.scheme,
host,
[OSSUtil encodeURL:objectKey]];
return [OSSTask taskWithResult:stringURL];
}
}]; }];
} }
......
...@@ -12,7 +12,7 @@ ...@@ -12,7 +12,7 @@
#define OSSDefine_h #define OSSDefine_h
#define OSSUAPrefix @"aliyun-sdk-ios" #define OSSUAPrefix @"aliyun-sdk-ios"
#define OSSSDKVersion @"2.6.0" #define OSSSDKVersion @"2.6.1"
#define OSSListBucketResultXMLTOKEN @"ListBucketResult" #define OSSListBucketResultXMLTOKEN @"ListBucketResult"
#define OSSNameXMLTOKEN @"Name" #define OSSNameXMLTOKEN @"Name"
......
...@@ -122,12 +122,13 @@ typedef OSSFederationToken * (^OSSGetFederationTokenBlock) (); ...@@ -122,12 +122,13 @@ typedef OSSFederationToken * (^OSSGetFederationTokenBlock) ();
/** /**
用明文AK/SK实现的加签器,建议只在测试模式时使用 用明文AK/SK实现的加签器,建议只在测试模式时使用
*/ */
@interface OSSPlainTextAKSKPairCredentialProvider : NSObject <OSSCredentialProvider> @interface OSSPlainTextAKSKPairCredentialProvider : NSObject <OSSCredentialProvider>
@property (nonatomic, strong) NSString * accessKey; @property (nonatomic, strong) NSString * accessKey;
@property (nonatomic, strong) NSString * secretKey; @property (nonatomic, strong) NSString * secretKey;
- (instancetype)initWithPlainTextAccessKey:(NSString *)accessKey - (instancetype)initWithPlainTextAccessKey:(NSString *)accessKey
secretKey:(NSString *)secretKey; secretKey:(NSString *)secretKey __attribute__((deprecated("We recommend the STS authentication mode on mobile")));
@end @end
/** /**
......
...@@ -417,6 +417,17 @@ ...@@ -417,6 +417,17 @@
} }
[sessionTask resume]; [sessionTask resume];
/**
内存泄露点,两个强引用指向 OSSNetworking 这个对象
1.sessionWithConfiguration:delegate:delegateQueue: 这个回调delegate会被强引用
2.当不再需要连接调用Session的时候,调用invalidateAndCancel直接关闭,或者调用finishTasksAndInvalidate等待当前Task结束后关闭。
3.这时Delegate会收到URLSession:didBecomeInvalidWithError:这个事件。
4.Delegate收到这个事件之后会被解引用。
*/
[_dataSession finishTasksAndInvalidate];
[_uploadFileSession finishTasksAndInvalidate];
return task; return task;
}] continueWithBlock:^id(OSSTask *task) { }] continueWithBlock:^id(OSSTask *task) {
......
...@@ -28,6 +28,9 @@ ...@@ -28,6 +28,9 @@
+ (NSString *)base64Md5ForData:(NSData *)data; + (NSString *)base64Md5ForData:(NSData *)data;
+ (NSString *)base64Md5ForFilePath:(NSString *)filePath; + (NSString *)base64Md5ForFilePath:(NSString *)filePath;
+ (NSString *)base64Md5ForFileURL:(NSURL *)fileURL; + (NSString *)base64Md5ForFileURL:(NSURL *)fileURL;
+ (NSString *)populateSubresourceStringFromParameter:(NSDictionary *)parameters;
+ (NSString *)populateQueryStringFromParameter:(NSDictionary *)parameters;
+ (BOOL)isSubresource:(NSString *)param;
+ (NSString *)sign:(NSString *)content withToken:(OSSFederationToken *)token; + (NSString *)sign:(NSString *)content withToken:(OSSFederationToken *)token;
+ (NSString *)getRelativePath:(NSString *)fullPath; + (NSString *)getRelativePath:(NSString *)fullPath;
+ (NSString *)detemineMimeTypeForFilePath:(NSString *)filePath uploadName:(NSString *)uploadName; + (NSString *)detemineMimeTypeForFilePath:(NSString *)filePath uploadName:(NSString *)uploadName;
......
...@@ -26,7 +26,7 @@ int32_t const CHUNK_SIZE = 8 * 1024; ...@@ -26,7 +26,7 @@ int32_t const CHUNK_SIZE = 8 * 1024;
NSData *clearTextData = [data dataUsingEncoding:NSUTF8StringEncoding]; NSData *clearTextData = [data dataUsingEncoding:NSUTF8StringEncoding];
uint8_t input[20]; uint8_t input[20];
CCHmac(kCCHmacAlgSHA1, [secretData bytes], [secretData length], [clearTextData bytes], [clearTextData length], input); CCHmac(kCCHmacAlgSHA1, [secretData bytes], [secretData length], [clearTextData bytes], [clearTextData length], input);
return [self calBase64WithData:input]; return [self calBase64WithData:input];
} }
...@@ -98,9 +98,9 @@ int32_t const CHUNK_SIZE = 8 * 1024; ...@@ -98,9 +98,9 @@ int32_t const CHUNK_SIZE = 8 * 1024;
+ (NSData *)constructHttpBodyForCreateBucketWithLocation:(NSString *)location { + (NSData *)constructHttpBodyForCreateBucketWithLocation:(NSString *)location {
NSString * body = [NSString stringWithFormat:@"<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" NSString * body = [NSString stringWithFormat:@"<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"
@"<CreateBucketConfiguration>\n" @"<CreateBucketConfiguration>\n"
@"<LocationConstraint>%@</LocationConstraint>\n" @"<LocationConstraint>%@</LocationConstraint>\n"
@"</CreateBucketConfiguration>\n", @"</CreateBucketConfiguration>\n",
location]; location];
OSSLogVerbose(@"constucted create bucket body:\n%@", body); OSSLogVerbose(@"constucted create bucket body:\n%@", body);
return [body dataUsingEncoding:NSUTF8StringEncoding]; return [body dataUsingEncoding:NSUTF8StringEncoding];
...@@ -256,6 +256,57 @@ int32_t const CHUNK_SIZE = 8 * 1024; ...@@ -256,6 +256,57 @@ int32_t const CHUNK_SIZE = 8 * 1024;
return [data base64EncodedStringWithOptions:0]; return [data base64EncodedStringWithOptions:0];
} }
+ (BOOL)isSubresource:(NSString *)param {
/****************************************************************
* define a constant array to contain all specified subresource */
static NSArray * OSSSubResourceARRAY = nil;
static dispatch_once_t onceToken;
dispatch_once(&onceToken, ^{
OSSSubResourceARRAY = @[
@"acl", @"uploads", @"location", @"cors", @"logging", @"website", @"referer", @"lifecycle", @"delete", @"append",
@"tagging", @"objectMeta", @"uploadId", @"partNumber", @"security-token", @"position", @"img", @"style",
@"styleName", @"replication", @"replicationProgress", @"replicationLocation", @"cname", @"bucketInfo", @"comp",
@"qos", @"live", @"status", @"vod", @"startTime", @"endTime", @"symlink", @"x-oss-process", @"response-content-type",
@"response-content-language", @"response-expires", @"response-cache-control", @"response-content-disposition", @"response-content-encoding"
];
});
/****************************************************************/
return [OSSSubResourceARRAY containsObject:param];
}
+ (NSString *)populateSubresourceStringFromParameter:(NSDictionary *)parameters {
NSMutableArray * subresource = [NSMutableArray new];
[parameters enumerateKeysAndObjectsUsingBlock:^(id _Nonnull key, id _Nonnull obj, BOOL * _Nonnull stop) {
NSString * keyStr = [key oss_trim];
NSString * valueStr = [obj oss_trim];
if (![OSSUtil isSubresource:keyStr]) {
return;
}
if ([valueStr length] == 0) {
[subresource addObject:keyStr];
} else {
[subresource addObject:[NSString stringWithFormat:@"%@=%@", keyStr, valueStr]];
}
}];
NSArray * sortedSubResource = [subresource sortedArrayUsingSelector:@selector(compare:)]; // 升序
return [sortedSubResource componentsJoinedByString:@"&"];
}
+ (NSString *)populateQueryStringFromParameter:(NSDictionary *)parameters {
NSMutableArray * subresource = [NSMutableArray new];
[parameters enumerateKeysAndObjectsUsingBlock:^(id _Nonnull key, id _Nonnull obj, BOOL * _Nonnull stop) {
NSString * keyStr = [OSSUtil encodeURL:[key oss_trim]];
NSString * valueStr = [OSSUtil encodeURL:[obj oss_trim]];
if ([valueStr length] == 0) {
[subresource addObject:keyStr];
} else {
[subresource addObject:[NSString stringWithFormat:@"%@=%@", keyStr, valueStr]];
}
}];
return [subresource componentsJoinedByString:@"&"];
}
+ (NSString *)sign:(NSString *)content withToken:(OSSFederationToken *)token { + (NSString *)sign:(NSString *)content withToken:(OSSFederationToken *)token {
NSString * sign = [OSSUtil calBase64Sha1WithData:content withSecret:token.tSecretKey]; NSString * sign = [OSSUtil calBase64Sha1WithData:content withSecret:token.tSecretKey];
return [NSString stringWithFormat:@"OSS %@:%@", token.tAccessKey, sign]; return [NSString stringWithFormat:@"OSS %@:%@", token.tAccessKey, sign];
...@@ -957,7 +1008,7 @@ int32_t const CHUNK_SIZE = 8 * 1024; ...@@ -957,7 +1008,7 @@ int32_t const CHUNK_SIZE = 8 * 1024;
@"ice": @"x-conference/x-cooltalk", @"ice": @"x-conference/x-cooltalk",
@"par ": @"text/plain-bas", @"par ": @"text/plain-bas",
@"yaml": @"text/yaml" @"yaml": @"text/yaml"
}; };
}); });
NSString * extention = nil; NSString * extention = nil;
......
Copyright (c) 2015 zhouzhuo Aliyun inc. Copyright (c) 2015 Aliyun inc.
Licensed under the Apache License, Version 2.0 (the "License"); Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License. you may not use this file except in compliance with the License.
......
## 简介
本文档主要介绍OSS iOS SDK的安装和使用。本文档假设您已经开通了阿里云OSS 服务,并创建了Access Key ID 和Access Key Secret。文中的ID 指的是Access Key ID,KEY 指的是Access Key Secret。如果您还没有开通或者还不了解OSS,请登录[OSS产品主页](http://www.aliyun.com/product/oss)获取更多的帮助。
### 环境要求:
- iOS系统版本:iOS 7.0以上
- 必须注册有Aliyun.com用户账户,并开通OSS服务。
-----
## 安装
### 直接引入Framework
需要引入OSS iOS SDK framework。
您可以在MacOS系统中直接使用在本工程生成framwork:
```bash
# clone工程
$ git clone git@github.com:aliyun/aliyun-oss-ios-sdk.git
# 进入目录
$ cd aliyun-oss-ios-sdk
# 执行打包脚本
$ sh ./buildFramework.sh
# 进入打包生成目录,AliyunOSSiOS.framework生成在该目录下
$ cd Products && ls
```
在Xcode中,直接把framework拖入您对应的Target下即可,在弹出框勾选`Copy items if needed`
### Pod依赖
如果工程是通过pod管理依赖,那么在Podfile中加入以下依赖即可,不需要再导入framework:
```
pod 'AliyunOSSiOS', '~> 2.5.4'
```
CocoaPods是一个非常优秀的依赖管理工具,推荐参考官方文档: [CocoaPods安装和使用教程](http://code4app.com/article/cocoapods-install-usage)
直接引入Framework和Pod依赖,两种方式选其一即可。
### 工程中引入头文件
```objc
#import <AliyunOSSiOS/OSSService.h>
```
注意,引入Framework后,需要在工程`Build Settings``Other Linker Flags`中加入`-ObjC`。如果工程此前已经设置过`-force_load`选项,那么,需要加入`-force_load <framework path>/AliyunOSSiOS`
### 兼容IPv6-Only网络
OSS移动端SDK为了解决无线网络下域名解析容易遭到劫持的问题,已经引入了HTTPDNS进行域名解析,直接使用IP请求OSS服务端。在IPv6-Only的网络下,可能会遇到兼容性问题。而APP官方近期发布了关于IPv6-only网络环境兼容的APP审核要求,为此,SDK从`2.5.0`版本开始已经做了兼容性处理。在新版本中,除了`-ObjC`的设置,还需要引入两个系统库:
```
libresolv.tbd
SystemConfiguration.framework
```
### 对于OSSTask的一些说明
所有调用api的操作,都会立即获得一个OSSTask,如:
```
OSSTask * task = [client getObject:get];
```
可以为这个Task设置一个延续(continution),以实现异步回调,如:
```
[task continueWithBlock: ^(OSSTask *task) {
// do something
...
return nil;
}];
```
也可以等待这个Task完成,以实现同步等待,如:
```
[task waitUntilFinished];
...
```
-----
## 快速入门
以下演示了上传、下载文件的基本流程。更多细节用法可以参考本工程的:
test资源:[点击查看](https://github.com/aliyun/AliyunOSSiOS/tree/master/AliyunOSSiOSTests)
或者:
demo示例: [点击查看](https://github.com/alibaba/alicloud-ios-demo)
### STEP-1. 初始化OSSClient
初始化主要完成Endpoint设置、鉴权方式设置、Client参数设置。其中,鉴权方式包含明文设置模式、自签名模式、STS鉴权模式。鉴权细节详见后面链接给出的官网完整文档的`访问控制`章节。
```objc
NSString *endpoint = @"http://oss-cn-hangzhou.aliyuncs.com";
// 明文设置secret的方式建议只在测试时使用,更多鉴权模式参考后面链接给出的官网完整文档的`访问控制`章节
id<OSSCredentialProvider> credential = [[OSSPlainTextAKSKPairCredentialProvider alloc] initWithPlainTextAccessKey:@"<your accesskeyId>"
secretKey:@"<your accessKeySecret>"];
client = [[OSSClient alloc] initWithEndpoint:endpoint credentialProvider:credential];
```
### STEP-2. 上传文件
这里假设您已经在控制台上拥有自己的Bucket。SDK的所有操作,都会返回一个`OSSTask`,您可以为这个task设置一个延续动作,等待其异步完成,也可以通过调用`waitUntilFinished`阻塞等待其完成。
```objc
OSSPutObjectRequest * put = [OSSPutObjectRequest new];
put.bucketName = @"<bucketName>";
put.objectKey = @"<objectKey>";
put.uploadingData = <NSData *>; // 直接上传NSData
put.uploadProgress = ^(int64_t bytesSent, int64_t totalByteSent, int64_t totalBytesExpectedToSend) {
NSLog(@"%lld, %lld, %lld", bytesSent, totalByteSent, totalBytesExpectedToSend);
};
OSSTask * putTask = [client putObject:put];
[putTask continueWithBlock:^id(OSSTask *task) {
if (!task.error) {
NSLog(@"upload object success!");
} else {
NSLog(@"upload object failed, error: %@" , task.error);
}
return nil;
}];
// 可以等待任务完成
// [putTask waitUntilFinished];
```
### STEP-3. 下载指定文件
下载一个指定`object``NSData`:
```objc
OSSGetObjectRequest * request = [OSSGetObjectRequest new];
request.bucketName = @"<bucketName>";
request.objectKey = @"<objectKey>";
request.downloadProgress = ^(int64_t bytesWritten, int64_t totalBytesWritten, int64_t totalBytesExpectedToWrite) {
NSLog(@"%lld, %lld, %lld", bytesWritten, totalBytesWritten, totalBytesExpectedToWrite);
};
OSSTask * getTask = [client getObject:request];
[getTask continueWithBlock:^id(OSSTask *task) {
if (!task.error) {
NSLog(@"download object success!");
OSSGetObjectResult * getResult = task.result;
NSLog(@"download result: %@", getResult.downloadedData);
} else {
NSLog(@"download object failed, error: %@" ,task.error);
}
return nil;
}];
// 如果需要阻塞等待任务完成
// [task waitUntilFinished];
```
-----
## 完整文档
SDK提供进阶的上传、下载功能、断点续传,以及文件管理、Bucket管理等功能。详见官方完整文档:[点击查看](http://help.aliyun.com/document_detail/oss/sdk/ios-sdk/preface.html?spm=5176.product8314910_oss.4.30.tK2G02)
-----
## API文档
[点击查看](http://aliyun.github.io/aliyun-oss-ios-sdk/)
-----
## 联系我们
* 阿里云OSS官方网站:http://oss.aliyun.com
* 阿里云OSS官方论坛:http://bbs.aliyun.com
* 阿里云OSS官方文档中心:http://www.aliyun.com/product/oss#Docs
* 阿里云官方技术支持 登录OSS控制台 https://home.console.aliyun.com -> 点击"工单系统"
-----
## License
Copyright (c) 2015 Aliyun.Inc.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
...@@ -14,7 +14,7 @@ PODS: ...@@ -14,7 +14,7 @@ PODS:
- AFNetworking/Serialization (3.1.0) - AFNetworking/Serialization (3.1.0)
- AFNetworking/UIKit (3.1.0): - AFNetworking/UIKit (3.1.0):
- AFNetworking/NSURLSession - AFNetworking/NSURLSession
- AliyunOSSiOS (2.6.0) - AliyunOSSiOS (2.6.1)
- Bugly (2.4.8) - Bugly (2.4.8)
- DACircularProgress (2.3.1) - DACircularProgress (2.3.1)
- DZNEmptyDataSet (1.8.1) - DZNEmptyDataSet (1.8.1)
...@@ -62,7 +62,7 @@ PODS: ...@@ -62,7 +62,7 @@ PODS:
- WYPopoverController (0.3.9) - WYPopoverController (0.3.9)
- WZLBadge (1.2.6) - WZLBadge (1.2.6)
- YXAlertController (1.0.7) - YXAlertController (1.0.7)
- YXKit (0.0.2) - YXKit (0.0.4)
DEPENDENCIES: DEPENDENCIES:
- AFNetworking (~> 3.1.0) - AFNetworking (~> 3.1.0)
...@@ -88,11 +88,11 @@ DEPENDENCIES: ...@@ -88,11 +88,11 @@ DEPENDENCIES:
- WYPopoverController (~> 0.3.9) - WYPopoverController (~> 0.3.9)
- WZLBadge (~> 1.2.5) - WZLBadge (~> 1.2.5)
- YXAlertController (~> 1.0.7) - YXAlertController (~> 1.0.7)
- YXKit (~> 0.0.2) - YXKit (~> 0.0.4)
SPEC CHECKSUMS: SPEC CHECKSUMS:
AFNetworking: 5e0e199f73d8626b11e79750991f5d173d1f8b67 AFNetworking: 5e0e199f73d8626b11e79750991f5d173d1f8b67
AliyunOSSiOS: '058b038cc82000dadb8f8e3893a97243124f2898' AliyunOSSiOS: 8174b695e09b136afe43a6af821c3ca71d423373
Bugly: da3c02408c14838d498429320545a8e439392978 Bugly: da3c02408c14838d498429320545a8e439392978
DACircularProgress: 4dd437c0fc3da5161cb289e07ac449493d41db71 DACircularProgress: 4dd437c0fc3da5161cb289e07ac449493d41db71
DZNEmptyDataSet: 9525833b9e68ac21c30253e1d3d7076cc828eaa7 DZNEmptyDataSet: 9525833b9e68ac21c30253e1d3d7076cc828eaa7
...@@ -116,8 +116,8 @@ SPEC CHECKSUMS: ...@@ -116,8 +116,8 @@ SPEC CHECKSUMS:
WYPopoverController: a9db25ac2841a686acdc0f3a99bdb21545db32f4 WYPopoverController: a9db25ac2841a686acdc0f3a99bdb21545db32f4
WZLBadge: 9ec779dcfd94c825518b395e8315fccaabff1bfa WZLBadge: 9ec779dcfd94c825518b395e8315fccaabff1bfa
YXAlertController: 68e27c48976fa9ecc0b82e63166b67863be8b70b YXAlertController: 68e27c48976fa9ecc0b82e63166b67863be8b70b
YXKit: 4869008392fd3ee0290ccc4dd657859b8a2e5939 YXKit: ed7714bc185dde43b1a5d1c4f7df760d9b2ec7f7
PODFILE CHECKSUM: 21f6d460b0f56a2bde65ba0bf298c5a07eacf877 PODFILE CHECKSUM: 962a8b96654703335e32ffd05a5bd7c50c577ac2
COCOAPODS: 1.2.1 COCOAPODS: 1.2.1
File mode changed from 100755 to 100644
...@@ -26,7 +26,7 @@ THE SOFTWARE. ...@@ -26,7 +26,7 @@ THE SOFTWARE.
## AliyunOSSiOS ## AliyunOSSiOS
Copyright (c) 2015 zhouzhuo Aliyun inc. Copyright (c) 2015 Aliyun inc.
Licensed under the Apache License, Version 2.0 (the "License"); Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License. you may not use this file except in compliance with the License.
......
...@@ -43,7 +43,7 @@ THE SOFTWARE. ...@@ -43,7 +43,7 @@ THE SOFTWARE.
</dict> </dict>
<dict> <dict>
<key>FooterText</key> <key>FooterText</key>
<string>Copyright (c) 2015 zhouzhuo Aliyun inc. <string>Copyright (c) 2015 Aliyun inc.
Licensed under the Apache License, Version 2.0 (the "License"); Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License. you may not use this file except in compliance with the License.
......
...@@ -26,7 +26,7 @@ THE SOFTWARE. ...@@ -26,7 +26,7 @@ THE SOFTWARE.
## AliyunOSSiOS ## AliyunOSSiOS
Copyright (c) 2015 zhouzhuo Aliyun inc. Copyright (c) 2015 Aliyun inc.
Licensed under the Apache License, Version 2.0 (the "License"); Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License. you may not use this file except in compliance with the License.
......
...@@ -43,7 +43,7 @@ THE SOFTWARE. ...@@ -43,7 +43,7 @@ THE SOFTWARE.
</dict> </dict>
<dict> <dict>
<key>FooterText</key> <key>FooterText</key>
<string>Copyright (c) 2015 zhouzhuo Aliyun inc. <string>Copyright (c) 2015 Aliyun inc.
Licensed under the Apache License, Version 2.0 (the "License"); Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License. you may not use this file except in compliance with the License.
......
...@@ -26,7 +26,7 @@ THE SOFTWARE. ...@@ -26,7 +26,7 @@ THE SOFTWARE.
## AliyunOSSiOS ## AliyunOSSiOS
Copyright (c) 2015 zhouzhuo Aliyun inc. Copyright (c) 2015 Aliyun inc.
Licensed under the Apache License, Version 2.0 (the "License"); Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License. you may not use this file except in compliance with the License.
......
...@@ -43,7 +43,7 @@ THE SOFTWARE. ...@@ -43,7 +43,7 @@ THE SOFTWARE.
</dict> </dict>
<dict> <dict>
<key>FooterText</key> <key>FooterText</key>
<string>Copyright (c) 2015 zhouzhuo Aliyun inc. <string>Copyright (c) 2015 Aliyun inc.
Licensed under the Apache License, Version 2.0 (the "License"); Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License. you may not use this file except in compliance with the License.
......
...@@ -169,14 +169,14 @@ ...@@ -169,14 +169,14 @@
+ (NSString *)timeInfoWithDate:(NSDate *)date; + (NSString *)timeInfoWithDate:(NSDate *)date;
+ (NSString *)timeInfoWithDateString:(NSString *)dateString; + (NSString *)timeInfoWithDateString:(NSString *)dateString;
/** // yyyy-MM-dd HH:mm:ss
* 分别获取yyyy-MM-dd/HH:mm:ss/yyyy-MM-dd HH:mm:ss格式的字符串 - (NSString *)httpParameterString;
*/ // yyyy-MM-dd
- (NSString *)ymdFormat; - (NSString *)yearMonthDayString;
- (NSString *)hmsFormat; /** yyyy-MM */
- (NSString *)ymdHmsFormat; - (NSString *)yearMonthString;
+ (NSString *)ymdFormat; - (NSString *)yearString;
+ (NSString *)hmsFormat; - (NSString *)monthString;
+ (NSString *)ymdHmsFormat; - (NSString *)dayString;
@end @end
...@@ -359,6 +359,30 @@ ...@@ -359,6 +359,30 @@
return [NSDate timeInfoWithDate:self]; return [NSDate timeInfoWithDate:self];
} }
- (NSString *)ymdFormat {
return [NSDate ymdFormat];
}
- (NSString *)hmsFormat {
return [NSDate hmsFormat];
}
- (NSString *)ymdHmsFormat {
return [NSDate ymdHmsFormat];
}
+ (NSString *)ymdFormat {
return @"yyyy-MM-dd";
}
+ (NSString *)hmsFormat {
return @"HH:mm:ss";
}
+ (NSString *)ymdHmsFormat {
return [NSString stringWithFormat:@"%@ %@", [self ymdFormat], [self hmsFormat]];
}
+ (NSString *)timeInfoWithDate:(NSDate *)date { + (NSString *)timeInfoWithDate:(NSDate *)date {
return [self timeInfoWithDateString:[self stringWithDate:date format:[self ymdHmsFormat]]]; return [self timeInfoWithDateString:[self stringWithDate:date format:[self ymdHmsFormat]]];
} }
...@@ -426,28 +450,59 @@ ...@@ -426,28 +450,59 @@
return @"1小时前"; return @"1小时前";
} }
- (NSString *)ymdFormat { + (NSString *)stringWithFormatter:(NSString *)dateFormatter andDate:(NSDate *)date {
return [NSDate ymdFormat]; if ([dateFormatter length] == 0) {
return nil;
}
struct tm *timeinfo;
char buffer[80];
time_t rawtime = (time_t)[date timeIntervalSince1970];
timeinfo = gmtime(&rawtime);
strftime(buffer, 80, [dateFormatter UTF8String], timeinfo);
return [NSString stringWithCString:buffer encoding:NSUTF8StringEncoding];
} }
- (NSString *)hmsFormat { - (NSString *)stringWithFormatter:(NSString *)dateFormatter {
return [NSDate hmsFormat];
if ([dateFormatter length] == 0) {
return nil;
}
// Change to Local time zone
NSTimeZone *zone = [NSTimeZone systemTimeZone];
NSInteger interval = [zone secondsFromGMTForDate:self];
NSDate *localDate = [self dateByAddingTimeInterval: interval];
return [[self class] stringWithFormatter:dateFormatter andDate:localDate];
} }
- (NSString *)ymdHmsFormat { - (NSString *)httpParameterString {
return [NSDate ymdHmsFormat]; return [self stringWithFormatter:@"%Y-%m-%d %H:%M:%S"];
} }
- (NSString *)yearMonthDayString {
+ (NSString *)ymdFormat { return [self stringWithFormatter:@"%Y-%m-%d"];
return @"yyyy-MM-dd";
} }
- (NSString *)yearMonthString {
+ (NSString *)hmsFormat { return [self stringWithFormatter:@"%Y-%m"];
return @"HH:mm:ss";
} }
- (NSString *)yearString {
+ (NSString *)ymdHmsFormat { NSString *strDate = [self yearMonthDayString];
return [NSString stringWithFormat:@"%@ %@", [self ymdFormat], [self hmsFormat]]; NSArray *arrDate = [strDate componentsSeparatedByString:@"-"];
return arrDate[0];
}
- (NSString *)monthString {
NSString *strDate = [self yearMonthDayString];
NSArray *arrDate = [strDate componentsSeparatedByString:@"-"];
return arrDate[1];
}
- (NSString *)dayString{
NSString *strDate = [self yearMonthDayString];
NSArray *arrDate = [strDate componentsSeparatedByString:@"-"];
return arrDate[2];
} }
- (NSDate *)offsetYears:(int)numYears { - (NSDate *)offsetYears:(int)numYears {
......
...@@ -13,16 +13,11 @@ ...@@ -13,16 +13,11 @@
/** /**
动画 动画
@param endpoint 结束坐标 @param endpoint 结束坐标
@param controlpoint 中间坐标 @param controlpoint 中间坐标
*/ */
- (void)startAnimationWithEndPoint:(CGPoint)endpoint withControlPoint:(CGPoint)controlpoint animateWithDuration:(NSTimeInterval)time; - (void)startAnimationWithEndPoint:(CGPoint)endpoint withControlPoint:(CGPoint)controlpoint animateWithDuration:(NSTimeInterval)time completed:(void(^)())completed;
/**
用于RAC订阅是否调用
@param layerAnimation 动画layer
*/
- (void)removeFromLayer:(CALayer *)layerAnimation;
@end @end
...@@ -10,15 +10,15 @@ ...@@ -10,15 +10,15 @@
@implementation UIImageView (AnimationView) @implementation UIImageView (AnimationView)
/** /**
动画 动画
@param endpoint 结束坐标 @param endpoint 结束坐标
@param controlpoint 中间坐标 @param controlpoint 中间坐标
*/ */
- (void)startAnimationWithEndPoint:(CGPoint)endpoint withControlPoint:(CGPoint)controlpoint animateWithDuration:(NSTimeInterval)time; - (void)startAnimationWithEndPoint:(CGPoint)endpoint withControlPoint:(CGPoint)controlpoint animateWithDuration:(NSTimeInterval)time completed:(void (^)())completed;
{ {
//终点 //终点
CGPoint endPoint = endpoint; CGPoint endPoint = endpoint;
//控点 //控点
...@@ -56,6 +56,10 @@ ...@@ -56,6 +56,10 @@
animGroup.delegate = self; animGroup.delegate = self;
[self.layer addAnimation:animGroup forKey:nil]; [self.layer addAnimation:animGroup forKey:nil];
[self performSelector:@selector(removeFromLayer:) withObject:self.layer afterDelay:time]; [self performSelector:@selector(removeFromLayer:) withObject:self.layer afterDelay:time];
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(time * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
completed();
});
} }
#pragma mark -动画完成后移除 #pragma mark -动画完成后移除
......
...@@ -25,7 +25,7 @@ abstract_target 'Lighting_base' do ...@@ -25,7 +25,7 @@ abstract_target 'Lighting_base' do
pod 'iCarousel', '~> 1.8.3' pod 'iCarousel', '~> 1.8.3'
pod 'UMengAnalytics' pod 'UMengAnalytics'
pod 'Bugly', '~> 2.4.7' pod 'Bugly', '~> 2.4.7'
pod 'YXKit', '~> 0.0.2' pod 'YXKit', '~> 0.0.4'
target 'Lighting' do target 'Lighting' do
end end
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment