Commit ee6a4576bd0daf1326d9bdd60ee24797dee9d4e1

Authored by 张旭
1 parent c3f0f8dc

提交

Showing 40 changed files with 4618 additions and 0 deletions
KS3SDKDemo/KS3SDKDemo.xcodeproj/project.pbxproj 0 → 100755
  1 +// !$*UTF8*$!
  2 +{
  3 + archiveVersion = 1;
  4 + classes = {
  5 + };
  6 + objectVersion = 46;
  7 + objects = {
  8 +
  9 +/* Begin PBXBuildFile section */
  10 + 459B691BDD20A82061BBF8DD /* libPods-KS3SDKDemo.a in Frameworks */ = {isa = PBXBuildFile; fileRef = F6DF70FD7F09025DFF977919 /* libPods-KS3SDKDemo.a */; };
  11 + D25908941F37FBC800EE4685 /* CNLiveNetManager.m in Sources */ = {isa = PBXBuildFile; fileRef = D25908931F37FBC800EE4685 /* CNLiveNetManager.m */; };
  12 + D25908971F37FC5A00EE4685 /* CNLiveReqSerialization.m in Sources */ = {isa = PBXBuildFile; fileRef = D25908961F37FC5A00EE4685 /* CNLiveReqSerialization.m */; };
  13 + D259089A1F38008D00EE4685 /* CNLiveCommonTools.m in Sources */ = {isa = PBXBuildFile; fileRef = D25908991F38008D00EE4685 /* CNLiveCommonTools.m */; };
  14 + D25908C01F3867D300EE4685 /* CNLiveUploadSDK.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = D25908BF1F3867BE00EE4685 /* CNLiveUploadSDK.framework */; };
  15 + DF7644461EB076920009D366 /* KS3Util.m in Sources */ = {isa = PBXBuildFile; fileRef = DF7644451EB076920009D366 /* KS3Util.m */; };
  16 + DFAA99E01EB048380099FD13 /* BucketViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = DFAA99D11EB048380099FD13 /* BucketViewController.m */; };
  17 + DFAA99E11EB048380099FD13 /* CreateBucketViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = DFAA99D31EB048380099FD13 /* CreateBucketViewController.m */; };
  18 + DFAA99E21EB048380099FD13 /* GetAllObjectsViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = DFAA99D51EB048380099FD13 /* GetAllObjectsViewController.m */; };
  19 + DFAA99E41EB048380099FD13 /* ListBucketViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = DFAA99D91EB048380099FD13 /* ListBucketViewController.m */; };
  20 + DFAA99E51EB048380099FD13 /* ObjectViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = DFAA99DB1EB048380099FD13 /* ObjectViewController.m */; };
  21 + DFAA99E61EB048380099FD13 /* ServiceViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = DFAA99DD1EB048380099FD13 /* ServiceViewController.m */; };
  22 + DFAA99E71EB048380099FD13 /* VideoViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = DFAA99DF1EB048380099FD13 /* VideoViewController.m */; };
  23 + DFAA99E91EB048400099FD13 /* 7.6M.mov in Resources */ = {isa = PBXBuildFile; fileRef = DFAA99E81EB048400099FD13 /* 7.6M.mov */; };
  24 + DFAFC6201EB0459800932063 /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = DFAFC61F1EB0459800932063 /* main.m */; };
  25 + DFAFC6231EB0459800932063 /* AppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = DFAFC6221EB0459800932063 /* AppDelegate.m */; };
  26 + DFAFC6261EB0459800932063 /* ViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = DFAFC6251EB0459800932063 /* ViewController.m */; };
  27 + DFAFC6291EB0459800932063 /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = DFAFC6271EB0459800932063 /* Main.storyboard */; };
  28 + DFAFC62B1EB0459800932063 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = DFAFC62A1EB0459800932063 /* Assets.xcassets */; };
  29 + DFAFC62E1EB0459800932063 /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = DFAFC62C1EB0459800932063 /* LaunchScreen.storyboard */; };
  30 + DFEC392C1F05056400A10A2E /* PerfViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = DFEC392B1F05056400A10A2E /* PerfViewController.m */; };
  31 +/* End PBXBuildFile section */
  32 +
  33 +/* Begin PBXFileReference section */
  34 + CF4E71A5C6DD3ADE8C97EC8F /* Pods-KS3SDKDemo.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-KS3SDKDemo.release.xcconfig"; path = "Pods/Target Support Files/Pods-KS3SDKDemo/Pods-KS3SDKDemo.release.xcconfig"; sourceTree = "<group>"; };
  35 + D25908921F37FBC800EE4685 /* CNLiveNetManager.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = CNLiveNetManager.h; sourceTree = "<group>"; };
  36 + D25908931F37FBC800EE4685 /* CNLiveNetManager.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = CNLiveNetManager.m; sourceTree = "<group>"; };
  37 + D25908951F37FC5A00EE4685 /* CNLiveReqSerialization.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = CNLiveReqSerialization.h; sourceTree = "<group>"; };
  38 + D25908961F37FC5A00EE4685 /* CNLiveReqSerialization.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = CNLiveReqSerialization.m; sourceTree = "<group>"; };
  39 + D25908981F38008D00EE4685 /* CNLiveCommonTools.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = CNLiveCommonTools.h; sourceTree = "<group>"; };
  40 + D25908991F38008D00EE4685 /* CNLiveCommonTools.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = CNLiveCommonTools.m; sourceTree = "<group>"; };
  41 + D25908BF1F3867BE00EE4685 /* CNLiveUploadSDK.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; path = CNLiveUploadSDK.framework; sourceTree = "<group>"; };
  42 + DF7644441EB076920009D366 /* KS3Util.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = KS3Util.h; sourceTree = "<group>"; };
  43 + DF7644451EB076920009D366 /* KS3Util.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = KS3Util.m; sourceTree = "<group>"; };
  44 + DFAA99D01EB048380099FD13 /* BucketViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = BucketViewController.h; sourceTree = "<group>"; };
  45 + DFAA99D11EB048380099FD13 /* BucketViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = BucketViewController.m; sourceTree = "<group>"; };
  46 + DFAA99D21EB048380099FD13 /* CreateBucketViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CreateBucketViewController.h; sourceTree = "<group>"; };
  47 + DFAA99D31EB048380099FD13 /* CreateBucketViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = CreateBucketViewController.m; sourceTree = "<group>"; };
  48 + DFAA99D41EB048380099FD13 /* GetAllObjectsViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = GetAllObjectsViewController.h; sourceTree = "<group>"; };
  49 + DFAA99D51EB048380099FD13 /* GetAllObjectsViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = GetAllObjectsViewController.m; sourceTree = "<group>"; };
  50 + DFAA99D81EB048380099FD13 /* ListBucketViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ListBucketViewController.h; sourceTree = "<group>"; };
  51 + DFAA99D91EB048380099FD13 /* ListBucketViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = ListBucketViewController.m; sourceTree = "<group>"; };
  52 + DFAA99DA1EB048380099FD13 /* ObjectViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ObjectViewController.h; sourceTree = "<group>"; };
  53 + DFAA99DB1EB048380099FD13 /* ObjectViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = ObjectViewController.m; sourceTree = "<group>"; };
  54 + DFAA99DC1EB048380099FD13 /* ServiceViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ServiceViewController.h; sourceTree = "<group>"; };
  55 + DFAA99DD1EB048380099FD13 /* ServiceViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = ServiceViewController.m; sourceTree = "<group>"; };
  56 + DFAA99DE1EB048380099FD13 /* VideoViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = VideoViewController.h; sourceTree = "<group>"; };
  57 + DFAA99DF1EB048380099FD13 /* VideoViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = VideoViewController.m; sourceTree = "<group>"; };
  58 + DFAA99E81EB048400099FD13 /* 7.6M.mov */ = {isa = PBXFileReference; lastKnownFileType = video.quicktime; path = 7.6M.mov; sourceTree = "<group>"; };
  59 + DFAFC61B1EB0459800932063 /* KS3SDKDemo.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = KS3SDKDemo.app; sourceTree = BUILT_PRODUCTS_DIR; };
  60 + DFAFC61F1EB0459800932063 /* main.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = main.m; sourceTree = "<group>"; };
  61 + DFAFC6211EB0459800932063 /* AppDelegate.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = AppDelegate.h; sourceTree = "<group>"; };
  62 + DFAFC6221EB0459800932063 /* AppDelegate.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = AppDelegate.m; sourceTree = "<group>"; };
  63 + DFAFC6241EB0459800932063 /* ViewController.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = ViewController.h; sourceTree = "<group>"; };
  64 + DFAFC6251EB0459800932063 /* ViewController.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = ViewController.m; sourceTree = "<group>"; };
  65 + DFAFC6281EB0459800932063 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = "<group>"; };
  66 + DFAFC62A1EB0459800932063 /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = "<group>"; };
  67 + DFAFC62D1EB0459800932063 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = "<group>"; };
  68 + DFAFC62F1EB0459800932063 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
  69 + DFEC392A1F05056400A10A2E /* PerfViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PerfViewController.h; sourceTree = "<group>"; };
  70 + DFEC392B1F05056400A10A2E /* PerfViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = PerfViewController.m; sourceTree = "<group>"; };
  71 + E20DA10A7DC7D91E7962A1F7 /* Pods-KS3SDKDemo.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-KS3SDKDemo.debug.xcconfig"; path = "Pods/Target Support Files/Pods-KS3SDKDemo/Pods-KS3SDKDemo.debug.xcconfig"; sourceTree = "<group>"; };
  72 + F6DF70FD7F09025DFF977919 /* libPods-KS3SDKDemo.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = "libPods-KS3SDKDemo.a"; sourceTree = BUILT_PRODUCTS_DIR; };
  73 +/* End PBXFileReference section */
  74 +
  75 +/* Begin PBXFrameworksBuildPhase section */
  76 + DFAFC6181EB0459800932063 /* Frameworks */ = {
  77 + isa = PBXFrameworksBuildPhase;
  78 + buildActionMask = 2147483647;
  79 + files = (
  80 + D25908C01F3867D300EE4685 /* CNLiveUploadSDK.framework in Frameworks */,
  81 + 459B691BDD20A82061BBF8DD /* libPods-KS3SDKDemo.a in Frameworks */,
  82 + );
  83 + runOnlyForDeploymentPostprocessing = 0;
  84 + };
  85 +/* End PBXFrameworksBuildPhase section */
  86 +
  87 +/* Begin PBXGroup section */
  88 + 423125D015674C8441662692 /* Frameworks */ = {
  89 + isa = PBXGroup;
  90 + children = (
  91 + F6DF70FD7F09025DFF977919 /* libPods-KS3SDKDemo.a */,
  92 + );
  93 + name = Frameworks;
  94 + sourceTree = "<group>";
  95 + };
  96 + A220EE01B3913B8B8E62EA07 /* Pods */ = {
  97 + isa = PBXGroup;
  98 + children = (
  99 + E20DA10A7DC7D91E7962A1F7 /* Pods-KS3SDKDemo.debug.xcconfig */,
  100 + CF4E71A5C6DD3ADE8C97EC8F /* Pods-KS3SDKDemo.release.xcconfig */,
  101 + );
  102 + name = Pods;
  103 + sourceTree = "<group>";
  104 + };
  105 + DFAFC6121EB0459800932063 = {
  106 + isa = PBXGroup;
  107 + children = (
  108 + DFAFC61D1EB0459800932063 /* KS3SDKDemo */,
  109 + DFAFC61C1EB0459800932063 /* Products */,
  110 + A220EE01B3913B8B8E62EA07 /* Pods */,
  111 + 423125D015674C8441662692 /* Frameworks */,
  112 + );
  113 + sourceTree = "<group>";
  114 + };
  115 + DFAFC61C1EB0459800932063 /* Products */ = {
  116 + isa = PBXGroup;
  117 + children = (
  118 + DFAFC61B1EB0459800932063 /* KS3SDKDemo.app */,
  119 + );
  120 + name = Products;
  121 + sourceTree = "<group>";
  122 + };
  123 + DFAFC61D1EB0459800932063 /* KS3SDKDemo */ = {
  124 + isa = PBXGroup;
  125 + children = (
  126 + D25908BF1F3867BE00EE4685 /* CNLiveUploadSDK.framework */,
  127 + DF7644441EB076920009D366 /* KS3Util.h */,
  128 + DF7644451EB076920009D366 /* KS3Util.m */,
  129 + DFAA99E81EB048400099FD13 /* 7.6M.mov */,
  130 + DFAA99D01EB048380099FD13 /* BucketViewController.h */,
  131 + DFAA99D11EB048380099FD13 /* BucketViewController.m */,
  132 + DFAA99D21EB048380099FD13 /* CreateBucketViewController.h */,
  133 + DFAA99D31EB048380099FD13 /* CreateBucketViewController.m */,
  134 + DFAA99D41EB048380099FD13 /* GetAllObjectsViewController.h */,
  135 + DFAA99D51EB048380099FD13 /* GetAllObjectsViewController.m */,
  136 + DFAA99D81EB048380099FD13 /* ListBucketViewController.h */,
  137 + DFAA99D91EB048380099FD13 /* ListBucketViewController.m */,
  138 + DFAA99DA1EB048380099FD13 /* ObjectViewController.h */,
  139 + DFAA99DB1EB048380099FD13 /* ObjectViewController.m */,
  140 + DFAA99DC1EB048380099FD13 /* ServiceViewController.h */,
  141 + DFAA99DD1EB048380099FD13 /* ServiceViewController.m */,
  142 + DFAA99DE1EB048380099FD13 /* VideoViewController.h */,
  143 + DFAA99DF1EB048380099FD13 /* VideoViewController.m */,
  144 + DFEC392A1F05056400A10A2E /* PerfViewController.h */,
  145 + DFEC392B1F05056400A10A2E /* PerfViewController.m */,
  146 + DFAFC6211EB0459800932063 /* AppDelegate.h */,
  147 + DFAFC6221EB0459800932063 /* AppDelegate.m */,
  148 + DFAFC6241EB0459800932063 /* ViewController.h */,
  149 + DFAFC6251EB0459800932063 /* ViewController.m */,
  150 + DFAFC6271EB0459800932063 /* Main.storyboard */,
  151 + DFAFC62A1EB0459800932063 /* Assets.xcassets */,
  152 + DFAFC62C1EB0459800932063 /* LaunchScreen.storyboard */,
  153 + DFAFC62F1EB0459800932063 /* Info.plist */,
  154 + DFAFC61E1EB0459800932063 /* Supporting Files */,
  155 + D25908921F37FBC800EE4685 /* CNLiveNetManager.h */,
  156 + D25908931F37FBC800EE4685 /* CNLiveNetManager.m */,
  157 + D25908951F37FC5A00EE4685 /* CNLiveReqSerialization.h */,
  158 + D25908961F37FC5A00EE4685 /* CNLiveReqSerialization.m */,
  159 + D25908981F38008D00EE4685 /* CNLiveCommonTools.h */,
  160 + D25908991F38008D00EE4685 /* CNLiveCommonTools.m */,
  161 + );
  162 + path = KS3SDKDemo;
  163 + sourceTree = "<group>";
  164 + };
  165 + DFAFC61E1EB0459800932063 /* Supporting Files */ = {
  166 + isa = PBXGroup;
  167 + children = (
  168 + DFAFC61F1EB0459800932063 /* main.m */,
  169 + );
  170 + name = "Supporting Files";
  171 + sourceTree = "<group>";
  172 + };
  173 +/* End PBXGroup section */
  174 +
  175 +/* Begin PBXNativeTarget section */
  176 + DFAFC61A1EB0459800932063 /* KS3SDKDemo */ = {
  177 + isa = PBXNativeTarget;
  178 + buildConfigurationList = DFAFC6321EB0459800932063 /* Build configuration list for PBXNativeTarget "KS3SDKDemo" */;
  179 + buildPhases = (
  180 + C47CC09B8DDC379C7B32AB02 /* [CP] Check Pods Manifest.lock */,
  181 + DFAFC6171EB0459800932063 /* Sources */,
  182 + DFAFC6181EB0459800932063 /* Frameworks */,
  183 + DFAFC6191EB0459800932063 /* Resources */,
  184 + B3F463B20F3E072DD7B629DF /* [CP] Embed Pods Frameworks */,
  185 + D8F05DAD7125117C9A41A2AE /* [CP] Copy Pods Resources */,
  186 + );
  187 + buildRules = (
  188 + );
  189 + dependencies = (
  190 + );
  191 + name = KS3SDKDemo;
  192 + productName = KS3SDKDemo;
  193 + productReference = DFAFC61B1EB0459800932063 /* KS3SDKDemo.app */;
  194 + productType = "com.apple.product-type.application";
  195 + };
  196 +/* End PBXNativeTarget section */
  197 +
  198 +/* Begin PBXProject section */
  199 + DFAFC6131EB0459800932063 /* Project object */ = {
  200 + isa = PBXProject;
  201 + attributes = {
  202 + LastUpgradeCheck = 0810;
  203 + ORGANIZATIONNAME = Kingsoft;
  204 + TargetAttributes = {
  205 + DFAFC61A1EB0459800932063 = {
  206 + CreatedOnToolsVersion = 8.1;
  207 + DevelopmentTeam = 94X49GG3ZW;
  208 + ProvisioningStyle = Automatic;
  209 + };
  210 + };
  211 + };
  212 + buildConfigurationList = DFAFC6161EB0459800932063 /* Build configuration list for PBXProject "KS3SDKDemo" */;
  213 + compatibilityVersion = "Xcode 3.2";
  214 + developmentRegion = English;
  215 + hasScannedForEncodings = 0;
  216 + knownRegions = (
  217 + en,
  218 + Base,
  219 + );
  220 + mainGroup = DFAFC6121EB0459800932063;
  221 + productRefGroup = DFAFC61C1EB0459800932063 /* Products */;
  222 + projectDirPath = "";
  223 + projectRoot = "";
  224 + targets = (
  225 + DFAFC61A1EB0459800932063 /* KS3SDKDemo */,
  226 + );
  227 + };
  228 +/* End PBXProject section */
  229 +
  230 +/* Begin PBXResourcesBuildPhase section */
  231 + DFAFC6191EB0459800932063 /* Resources */ = {
  232 + isa = PBXResourcesBuildPhase;
  233 + buildActionMask = 2147483647;
  234 + files = (
  235 + DFAA99E91EB048400099FD13 /* 7.6M.mov in Resources */,
  236 + DFAFC62E1EB0459800932063 /* LaunchScreen.storyboard in Resources */,
  237 + DFAFC62B1EB0459800932063 /* Assets.xcassets in Resources */,
  238 + DFAFC6291EB0459800932063 /* Main.storyboard in Resources */,
  239 + );
  240 + runOnlyForDeploymentPostprocessing = 0;
  241 + };
  242 +/* End PBXResourcesBuildPhase section */
  243 +
  244 +/* Begin PBXShellScriptBuildPhase section */
  245 + B3F463B20F3E072DD7B629DF /* [CP] Embed Pods Frameworks */ = {
  246 + isa = PBXShellScriptBuildPhase;
  247 + buildActionMask = 2147483647;
  248 + files = (
  249 + );
  250 + inputPaths = (
  251 + );
  252 + name = "[CP] Embed Pods Frameworks";
  253 + outputPaths = (
  254 + );
  255 + runOnlyForDeploymentPostprocessing = 0;
  256 + shellPath = /bin/sh;
  257 + shellScript = "\"${SRCROOT}/Pods/Target Support Files/Pods-KS3SDKDemo/Pods-KS3SDKDemo-frameworks.sh\"\n";
  258 + showEnvVarsInLog = 0;
  259 + };
  260 + C47CC09B8DDC379C7B32AB02 /* [CP] Check Pods Manifest.lock */ = {
  261 + isa = PBXShellScriptBuildPhase;
  262 + buildActionMask = 2147483647;
  263 + files = (
  264 + );
  265 + inputPaths = (
  266 + );
  267 + name = "[CP] Check Pods Manifest.lock";
  268 + outputPaths = (
  269 + );
  270 + runOnlyForDeploymentPostprocessing = 0;
  271 + shellPath = /bin/sh;
  272 + shellScript = "diff \"${PODS_ROOT}/../Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [ $? != 0 ] ; then\n # print error to STDERR\n echo \"error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\" >&2\n exit 1\nfi\n";
  273 + showEnvVarsInLog = 0;
  274 + };
  275 + D8F05DAD7125117C9A41A2AE /* [CP] Copy Pods Resources */ = {
  276 + isa = PBXShellScriptBuildPhase;
  277 + buildActionMask = 2147483647;
  278 + files = (
  279 + );
  280 + inputPaths = (
  281 + );
  282 + name = "[CP] Copy Pods Resources";
  283 + outputPaths = (
  284 + );
  285 + runOnlyForDeploymentPostprocessing = 0;
  286 + shellPath = /bin/sh;
  287 + shellScript = "\"${SRCROOT}/Pods/Target Support Files/Pods-KS3SDKDemo/Pods-KS3SDKDemo-resources.sh\"\n";
  288 + showEnvVarsInLog = 0;
  289 + };
  290 +/* End PBXShellScriptBuildPhase section */
  291 +
  292 +/* Begin PBXSourcesBuildPhase section */
  293 + DFAFC6171EB0459800932063 /* Sources */ = {
  294 + isa = PBXSourcesBuildPhase;
  295 + buildActionMask = 2147483647;
  296 + files = (
  297 + DFAFC6261EB0459800932063 /* ViewController.m in Sources */,
  298 + DFAA99E11EB048380099FD13 /* CreateBucketViewController.m in Sources */,
  299 + DFAA99E71EB048380099FD13 /* VideoViewController.m in Sources */,
  300 + DFEC392C1F05056400A10A2E /* PerfViewController.m in Sources */,
  301 + D259089A1F38008D00EE4685 /* CNLiveCommonTools.m in Sources */,
  302 + D25908941F37FBC800EE4685 /* CNLiveNetManager.m in Sources */,
  303 + DFAFC6231EB0459800932063 /* AppDelegate.m in Sources */,
  304 + DFAA99E01EB048380099FD13 /* BucketViewController.m in Sources */,
  305 + DF7644461EB076920009D366 /* KS3Util.m in Sources */,
  306 + DFAA99E21EB048380099FD13 /* GetAllObjectsViewController.m in Sources */,
  307 + D25908971F37FC5A00EE4685 /* CNLiveReqSerialization.m in Sources */,
  308 + DFAA99E51EB048380099FD13 /* ObjectViewController.m in Sources */,
  309 + DFAA99E41EB048380099FD13 /* ListBucketViewController.m in Sources */,
  310 + DFAA99E61EB048380099FD13 /* ServiceViewController.m in Sources */,
  311 + DFAFC6201EB0459800932063 /* main.m in Sources */,
  312 + );
  313 + runOnlyForDeploymentPostprocessing = 0;
  314 + };
  315 +/* End PBXSourcesBuildPhase section */
  316 +
  317 +/* Begin PBXVariantGroup section */
  318 + DFAFC6271EB0459800932063 /* Main.storyboard */ = {
  319 + isa = PBXVariantGroup;
  320 + children = (
  321 + DFAFC6281EB0459800932063 /* Base */,
  322 + );
  323 + name = Main.storyboard;
  324 + sourceTree = "<group>";
  325 + };
  326 + DFAFC62C1EB0459800932063 /* LaunchScreen.storyboard */ = {
  327 + isa = PBXVariantGroup;
  328 + children = (
  329 + DFAFC62D1EB0459800932063 /* Base */,
  330 + );
  331 + name = LaunchScreen.storyboard;
  332 + sourceTree = "<group>";
  333 + };
  334 +/* End PBXVariantGroup section */
  335 +
  336 +/* Begin XCBuildConfiguration section */
  337 + DFAFC6301EB0459800932063 /* Debug */ = {
  338 + isa = XCBuildConfiguration;
  339 + buildSettings = {
  340 + ALWAYS_SEARCH_USER_PATHS = NO;
  341 + CLANG_ANALYZER_NONNULL = YES;
  342 + CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
  343 + CLANG_CXX_LIBRARY = "libc++";
  344 + CLANG_ENABLE_MODULES = YES;
  345 + CLANG_ENABLE_OBJC_ARC = YES;
  346 + CLANG_WARN_BOOL_CONVERSION = YES;
  347 + CLANG_WARN_CONSTANT_CONVERSION = YES;
  348 + CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
  349 + CLANG_WARN_DOCUMENTATION_COMMENTS = YES;
  350 + CLANG_WARN_EMPTY_BODY = YES;
  351 + CLANG_WARN_ENUM_CONVERSION = YES;
  352 + CLANG_WARN_INFINITE_RECURSION = YES;
  353 + CLANG_WARN_INT_CONVERSION = YES;
  354 + CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
  355 + CLANG_WARN_SUSPICIOUS_MOVE = YES;
  356 + CLANG_WARN_SUSPICIOUS_MOVES = YES;
  357 + CLANG_WARN_UNREACHABLE_CODE = YES;
  358 + CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
  359 + "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
  360 + COPY_PHASE_STRIP = NO;
  361 + DEBUG_INFORMATION_FORMAT = dwarf;
  362 + ENABLE_STRICT_OBJC_MSGSEND = YES;
  363 + ENABLE_TESTABILITY = YES;
  364 + GCC_C_LANGUAGE_STANDARD = gnu99;
  365 + GCC_DYNAMIC_NO_PIC = NO;
  366 + GCC_NO_COMMON_BLOCKS = YES;
  367 + GCC_OPTIMIZATION_LEVEL = 0;
  368 + GCC_PREPROCESSOR_DEFINITIONS = (
  369 + "DEBUG=1",
  370 + "$(inherited)",
  371 + );
  372 + GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
  373 + GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR;
  374 + GCC_WARN_UNDECLARED_SELECTOR = YES;
  375 + GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
  376 + GCC_WARN_UNUSED_FUNCTION = YES;
  377 + GCC_WARN_UNUSED_VARIABLE = YES;
  378 + IPHONEOS_DEPLOYMENT_TARGET = 10.1;
  379 + MTL_ENABLE_DEBUG_INFO = YES;
  380 + ONLY_ACTIVE_ARCH = YES;
  381 + SDKROOT = iphoneos;
  382 + TARGETED_DEVICE_FAMILY = "1,2";
  383 + };
  384 + name = Debug;
  385 + };
  386 + DFAFC6311EB0459800932063 /* Release */ = {
  387 + isa = XCBuildConfiguration;
  388 + buildSettings = {
  389 + ALWAYS_SEARCH_USER_PATHS = NO;
  390 + CLANG_ANALYZER_NONNULL = YES;
  391 + CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
  392 + CLANG_CXX_LIBRARY = "libc++";
  393 + CLANG_ENABLE_MODULES = YES;
  394 + CLANG_ENABLE_OBJC_ARC = YES;
  395 + CLANG_WARN_BOOL_CONVERSION = YES;
  396 + CLANG_WARN_CONSTANT_CONVERSION = YES;
  397 + CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
  398 + CLANG_WARN_DOCUMENTATION_COMMENTS = YES;
  399 + CLANG_WARN_EMPTY_BODY = YES;
  400 + CLANG_WARN_ENUM_CONVERSION = YES;
  401 + CLANG_WARN_INFINITE_RECURSION = YES;
  402 + CLANG_WARN_INT_CONVERSION = YES;
  403 + CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
  404 + CLANG_WARN_SUSPICIOUS_MOVE = YES;
  405 + CLANG_WARN_SUSPICIOUS_MOVES = YES;
  406 + CLANG_WARN_UNREACHABLE_CODE = YES;
  407 + CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
  408 + "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
  409 + COPY_PHASE_STRIP = NO;
  410 + DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
  411 + ENABLE_NS_ASSERTIONS = NO;
  412 + ENABLE_STRICT_OBJC_MSGSEND = YES;
  413 + GCC_C_LANGUAGE_STANDARD = gnu99;
  414 + GCC_NO_COMMON_BLOCKS = YES;
  415 + GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
  416 + GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR;
  417 + GCC_WARN_UNDECLARED_SELECTOR = YES;
  418 + GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
  419 + GCC_WARN_UNUSED_FUNCTION = YES;
  420 + GCC_WARN_UNUSED_VARIABLE = YES;
  421 + IPHONEOS_DEPLOYMENT_TARGET = 10.1;
  422 + MTL_ENABLE_DEBUG_INFO = NO;
  423 + SDKROOT = iphoneos;
  424 + TARGETED_DEVICE_FAMILY = "1,2";
  425 + VALIDATE_PRODUCT = YES;
  426 + };
  427 + name = Release;
  428 + };
  429 + DFAFC6331EB0459800932063 /* Debug */ = {
  430 + isa = XCBuildConfiguration;
  431 + baseConfigurationReference = E20DA10A7DC7D91E7962A1F7 /* Pods-KS3SDKDemo.debug.xcconfig */;
  432 + buildSettings = {
  433 + ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
  434 + DEVELOPMENT_TEAM = 94X49GG3ZW;
  435 + FRAMEWORK_SEARCH_PATHS = (
  436 + "$(inherited)",
  437 + "$(PROJECT_DIR)/KS3SDKDemo",
  438 + );
  439 + INFOPLIST_FILE = KS3SDKDemo/Info.plist;
  440 + LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
  441 + PRODUCT_BUNDLE_IDENTIFIER = com.rd.XpkUISDKDemo;
  442 + PRODUCT_NAME = "$(TARGET_NAME)";
  443 + };
  444 + name = Debug;
  445 + };
  446 + DFAFC6341EB0459800932063 /* Release */ = {
  447 + isa = XCBuildConfiguration;
  448 + baseConfigurationReference = CF4E71A5C6DD3ADE8C97EC8F /* Pods-KS3SDKDemo.release.xcconfig */;
  449 + buildSettings = {
  450 + ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
  451 + DEVELOPMENT_TEAM = 94X49GG3ZW;
  452 + FRAMEWORK_SEARCH_PATHS = (
  453 + "$(inherited)",
  454 + "$(PROJECT_DIR)/KS3SDKDemo",
  455 + );
  456 + INFOPLIST_FILE = KS3SDKDemo/Info.plist;
  457 + LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
  458 + PRODUCT_BUNDLE_IDENTIFIER = com.rd.XpkUISDKDemo;
  459 + PRODUCT_NAME = "$(TARGET_NAME)";
  460 + };
  461 + name = Release;
  462 + };
  463 +/* End XCBuildConfiguration section */
  464 +
  465 +/* Begin XCConfigurationList section */
  466 + DFAFC6161EB0459800932063 /* Build configuration list for PBXProject "KS3SDKDemo" */ = {
  467 + isa = XCConfigurationList;
  468 + buildConfigurations = (
  469 + DFAFC6301EB0459800932063 /* Debug */,
  470 + DFAFC6311EB0459800932063 /* Release */,
  471 + );
  472 + defaultConfigurationIsVisible = 0;
  473 + defaultConfigurationName = Release;
  474 + };
  475 + DFAFC6321EB0459800932063 /* Build configuration list for PBXNativeTarget "KS3SDKDemo" */ = {
  476 + isa = XCConfigurationList;
  477 + buildConfigurations = (
  478 + DFAFC6331EB0459800932063 /* Debug */,
  479 + DFAFC6341EB0459800932063 /* Release */,
  480 + );
  481 + defaultConfigurationIsVisible = 0;
  482 + defaultConfigurationName = Release;
  483 + };
  484 +/* End XCConfigurationList section */
  485 + };
  486 + rootObject = DFAFC6131EB0459800932063 /* Project object */;
  487 +}
... ...
KS3SDKDemo/KS3SDKDemo.xcodeproj/xcuserdata/cnlive.xcuserdatad/xcschemes/KS3SDKDemo.xcscheme 0 → 100644
  1 +<?xml version="1.0" encoding="UTF-8"?>
  2 +<Scheme
  3 + LastUpgradeVersion = "0830"
  4 + version = "1.3">
  5 + <BuildAction
  6 + parallelizeBuildables = "YES"
  7 + buildImplicitDependencies = "YES">
  8 + <BuildActionEntries>
  9 + <BuildActionEntry
  10 + buildForTesting = "YES"
  11 + buildForRunning = "YES"
  12 + buildForProfiling = "YES"
  13 + buildForArchiving = "YES"
  14 + buildForAnalyzing = "YES">
  15 + <BuildableReference
  16 + BuildableIdentifier = "primary"
  17 + BlueprintIdentifier = "DFAFC61A1EB0459800932063"
  18 + BuildableName = "KS3SDKDemo.app"
  19 + BlueprintName = "KS3SDKDemo"
  20 + ReferencedContainer = "container:KS3SDKDemo.xcodeproj">
  21 + </BuildableReference>
  22 + </BuildActionEntry>
  23 + </BuildActionEntries>
  24 + </BuildAction>
  25 + <TestAction
  26 + buildConfiguration = "Debug"
  27 + selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
  28 + selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
  29 + language = ""
  30 + shouldUseLaunchSchemeArgsEnv = "YES">
  31 + <Testables>
  32 + </Testables>
  33 + <MacroExpansion>
  34 + <BuildableReference
  35 + BuildableIdentifier = "primary"
  36 + BlueprintIdentifier = "DFAFC61A1EB0459800932063"
  37 + BuildableName = "KS3SDKDemo.app"
  38 + BlueprintName = "KS3SDKDemo"
  39 + ReferencedContainer = "container:KS3SDKDemo.xcodeproj">
  40 + </BuildableReference>
  41 + </MacroExpansion>
  42 + <AdditionalOptions>
  43 + </AdditionalOptions>
  44 + </TestAction>
  45 + <LaunchAction
  46 + buildConfiguration = "Debug"
  47 + selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
  48 + selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
  49 + language = ""
  50 + launchStyle = "0"
  51 + useCustomWorkingDirectory = "NO"
  52 + ignoresPersistentStateOnLaunch = "NO"
  53 + debugDocumentVersioning = "YES"
  54 + debugServiceExtension = "internal"
  55 + allowLocationSimulation = "YES">
  56 + <BuildableProductRunnable
  57 + runnableDebuggingMode = "0">
  58 + <BuildableReference
  59 + BuildableIdentifier = "primary"
  60 + BlueprintIdentifier = "DFAFC61A1EB0459800932063"
  61 + BuildableName = "KS3SDKDemo.app"
  62 + BlueprintName = "KS3SDKDemo"
  63 + ReferencedContainer = "container:KS3SDKDemo.xcodeproj">
  64 + </BuildableReference>
  65 + </BuildableProductRunnable>
  66 + <AdditionalOptions>
  67 + <AdditionalOption
  68 + key = "NSZombieEnabled"
  69 + value = "YES"
  70 + isEnabled = "YES">
  71 + </AdditionalOption>
  72 + </AdditionalOptions>
  73 + </LaunchAction>
  74 + <ProfileAction
  75 + buildConfiguration = "Release"
  76 + shouldUseLaunchSchemeArgsEnv = "YES"
  77 + savedToolIdentifier = ""
  78 + useCustomWorkingDirectory = "NO"
  79 + debugDocumentVersioning = "YES">
  80 + <BuildableProductRunnable
  81 + runnableDebuggingMode = "0">
  82 + <BuildableReference
  83 + BuildableIdentifier = "primary"
  84 + BlueprintIdentifier = "DFAFC61A1EB0459800932063"
  85 + BuildableName = "KS3SDKDemo.app"
  86 + BlueprintName = "KS3SDKDemo"
  87 + ReferencedContainer = "container:KS3SDKDemo.xcodeproj">
  88 + </BuildableReference>
  89 + </BuildableProductRunnable>
  90 + </ProfileAction>
  91 + <AnalyzeAction
  92 + buildConfiguration = "Debug">
  93 + </AnalyzeAction>
  94 + <ArchiveAction
  95 + buildConfiguration = "Release"
  96 + revealArchiveInOrganizer = "YES">
  97 + </ArchiveAction>
  98 +</Scheme>
... ...
KS3SDKDemo/KS3SDKDemo/7.6M.mov 0 → 100755
No preview for this file type
KS3SDKDemo/KS3SDKDemo/AppDelegate.h 0 → 100755
  1 +//
  2 +// AppDelegate.h
  3 +// KS3SDKDemo-Token
  4 +//
  5 +// Created by JackWong on 15/4/28.
  6 +// Copyright (c) 2015年 Jack Wong. All rights reserved.
  7 +//
  8 +
  9 +#import <UIKit/UIKit.h>
  10 +//extern NSString * const strAccessKey;
  11 +//extern NSString * const strSecretKey;
  12 +
  13 +#define AppId @"60_j5xilfyl12"
  14 +#define AppKey @"8b58d3dcdd828359e6113d5531029801e5d2b53e9a980c"
  15 +
  16 +@interface AppDelegate : UIResponder <UIApplicationDelegate>
  17 +
  18 +@property (strong, nonatomic) UIWindow *window;
  19 +
  20 +
  21 +@end
  22 +
... ...
KS3SDKDemo/KS3SDKDemo/AppDelegate.m 0 → 100755
  1 +//
  2 +// AppDelegate.m
  3 +// KS3SDKDemo-Token
  4 +//
  5 +// Created by JackWong on 15/4/28.
  6 +// Copyright (c) 2015年 Jack Wong. All rights reserved.
  7 +//
  8 +
  9 +
  10 +#import "AppDelegate.h"
  11 +#import <KS3YunSDK.h>
  12 +
  13 +#import <CNLiveUploadSDK/CNLiveUpload.h>
  14 +#warning AK/SK Setting
  15 +// **** 设置用户的AK/SK以获取token,用于模拟从app服务器端获取token,真实使用场景为,app服务器返回token
  16 +//NSString * const strAccessKey = @"YOUR_APP_KEY";
  17 +//NSString * const strSecretKey = @"YOUR_APP_SECRET";
  18 +
  19 +@interface AppDelegate ()
  20 +
  21 +@end
  22 +
  23 +@implementation AppDelegate
  24 +
  25 +
  26 +- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
  27 + // Override point for customization after application launch.
  28 + [[KS3Client initialize] setBucketDomainWithRegion:KS3BucketBeijing];
  29 +
  30 + //使用绑定bucket的自定义域名可以通过下面这行设置endpoint
  31 + //[[KS3Client initialize] setBucketDomain:@"www.abc.com"];
  32 +
  33 + [CNLiveUpload setAppId:AppId appKey:AppKey isTestEnvironment:YES];
  34 + return YES;
  35 +}
  36 +
  37 +- (void)applicationWillResignActive:(UIApplication *)application {
  38 + // Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state.
  39 + // Use this method to pause ongoing tasks, disable timers, and throttle down OpenGL ES frame rates. Games should use this method to pause the game.
  40 +}
  41 +
  42 +- (void)applicationDidEnterBackground:(UIApplication *)application {
  43 + // Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later.
  44 + // If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits.
  45 +}
  46 +
  47 +- (void)applicationWillEnterForeground:(UIApplication *)application {
  48 + // Called as part of the transition from the background to the inactive state; here you can undo many of the changes made on entering the background.
  49 +}
  50 +
  51 +- (void)applicationDidBecomeActive:(UIApplication *)application {
  52 + // Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface.
  53 +}
  54 +
  55 +- (void)applicationWillTerminate:(UIApplication *)application {
  56 + // Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:.
  57 +}
  58 +
  59 +@end
... ...
KS3SDKDemo/KS3SDKDemo/Assets.xcassets/AppIcon.appiconset/Contents.json 0 → 100755
  1 +{
  2 + "images" : [
  3 + {
  4 + "idiom" : "iphone",
  5 + "size" : "20x20",
  6 + "scale" : "2x"
  7 + },
  8 + {
  9 + "idiom" : "iphone",
  10 + "size" : "20x20",
  11 + "scale" : "3x"
  12 + },
  13 + {
  14 + "idiom" : "iphone",
  15 + "size" : "29x29",
  16 + "scale" : "2x"
  17 + },
  18 + {
  19 + "idiom" : "iphone",
  20 + "size" : "29x29",
  21 + "scale" : "3x"
  22 + },
  23 + {
  24 + "idiom" : "iphone",
  25 + "size" : "40x40",
  26 + "scale" : "2x"
  27 + },
  28 + {
  29 + "idiom" : "iphone",
  30 + "size" : "40x40",
  31 + "scale" : "3x"
  32 + },
  33 + {
  34 + "idiom" : "iphone",
  35 + "size" : "60x60",
  36 + "scale" : "2x"
  37 + },
  38 + {
  39 + "idiom" : "iphone",
  40 + "size" : "60x60",
  41 + "scale" : "3x"
  42 + },
  43 + {
  44 + "idiom" : "ipad",
  45 + "size" : "20x20",
  46 + "scale" : "1x"
  47 + },
  48 + {
  49 + "idiom" : "ipad",
  50 + "size" : "20x20",
  51 + "scale" : "2x"
  52 + },
  53 + {
  54 + "idiom" : "ipad",
  55 + "size" : "29x29",
  56 + "scale" : "1x"
  57 + },
  58 + {
  59 + "idiom" : "ipad",
  60 + "size" : "29x29",
  61 + "scale" : "2x"
  62 + },
  63 + {
  64 + "idiom" : "ipad",
  65 + "size" : "40x40",
  66 + "scale" : "1x"
  67 + },
  68 + {
  69 + "idiom" : "ipad",
  70 + "size" : "40x40",
  71 + "scale" : "2x"
  72 + },
  73 + {
  74 + "idiom" : "ipad",
  75 + "size" : "76x76",
  76 + "scale" : "1x"
  77 + },
  78 + {
  79 + "idiom" : "ipad",
  80 + "size" : "76x76",
  81 + "scale" : "2x"
  82 + },
  83 + {
  84 + "idiom" : "ipad",
  85 + "size" : "83.5x83.5",
  86 + "scale" : "2x"
  87 + }
  88 + ],
  89 + "info" : {
  90 + "version" : 1,
  91 + "author" : "xcode"
  92 + }
  93 +}
0 94 \ No newline at end of file
... ...
KS3SDKDemo/KS3SDKDemo/Base.lproj/LaunchScreen.storyboard 0 → 100755
  1 +<?xml version="1.0" encoding="UTF-8" standalone="no"?>
  2 +<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="11134" systemVersion="15F34" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" launchScreen="YES" useTraitCollections="YES" colorMatched="YES" initialViewController="01J-lp-oVM">
  3 + <dependencies>
  4 + <plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="11106"/>
  5 + <capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
  6 + </dependencies>
  7 + <scenes>
  8 + <!--View Controller-->
  9 + <scene sceneID="EHf-IW-A2E">
  10 + <objects>
  11 + <viewController id="01J-lp-oVM" sceneMemberID="viewController">
  12 + <layoutGuides>
  13 + <viewControllerLayoutGuide type="top" id="Llm-lL-Icb"/>
  14 + <viewControllerLayoutGuide type="bottom" id="xb3-aO-Qok"/>
  15 + </layoutGuides>
  16 + <view key="view" contentMode="scaleToFill" id="Ze5-6b-2t3">
  17 + <rect key="frame" x="0.0" y="0.0" width="375" height="667"/>
  18 + <autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
  19 + <color key="backgroundColor" red="1" green="1" blue="1" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
  20 + </view>
  21 + </viewController>
  22 + <placeholder placeholderIdentifier="IBFirstResponder" id="iYj-Kq-Ea1" userLabel="First Responder" sceneMemberID="firstResponder"/>
  23 + </objects>
  24 + <point key="canvasLocation" x="53" y="375"/>
  25 + </scene>
  26 + </scenes>
  27 +</document>
... ...
KS3SDKDemo/KS3SDKDemo/Base.lproj/Main.storyboard 0 → 100755
  1 +<?xml version="1.0" encoding="UTF-8"?>
  2 +<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="11542" systemVersion="16F73" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" colorMatched="YES" initialViewController="wFT-hm-9Q3">
  3 + <device id="retina4_7" orientation="portrait">
  4 + <adaptation id="fullscreen"/>
  5 + </device>
  6 + <dependencies>
  7 + <deployment identifier="iOS"/>
  8 + <plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="11524"/>
  9 + <capability name="Constraints to layout margins" minToolsVersion="6.0"/>
  10 + <capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
  11 + </dependencies>
  12 + <scenes>
  13 + <!--Navigation Controller-->
  14 + <scene sceneID="AAj-0b-JYS">
  15 + <objects>
  16 + <navigationController id="wFT-hm-9Q3" sceneMemberID="viewController">
  17 + <navigationBar key="navigationBar" contentMode="scaleToFill" id="SDg-G1-Tnw">
  18 + <rect key="frame" x="0.0" y="0.0" width="320" height="44"/>
  19 + <autoresizingMask key="autoresizingMask"/>
  20 + </navigationBar>
  21 + <connections>
  22 + <segue destination="JV9-zb-AoK" kind="relationship" relationship="rootViewController" id="Be7-Zg-65v"/>
  23 + </connections>
  24 + </navigationController>
  25 + <placeholder placeholderIdentifier="IBFirstResponder" id="hxo-Gk-CUW" userLabel="First Responder" sceneMemberID="firstResponder"/>
  26 + </objects>
  27 + <point key="canvasLocation" x="449" y="432"/>
  28 + </scene>
  29 + <!--View Controller-->
  30 + <scene sceneID="Pax-np-I86">
  31 + <objects>
  32 + <viewController id="JV9-zb-AoK" customClass="ViewController" sceneMemberID="viewController">
  33 + <layoutGuides>
  34 + <viewControllerLayoutGuide type="top" id="Vge-bl-AZF"/>
  35 + <viewControllerLayoutGuide type="bottom" id="CU9-WC-0d2"/>
  36 + </layoutGuides>
  37 + <view key="view" contentMode="scaleToFill" id="P2b-LU-zX2">
  38 + <rect key="frame" x="0.0" y="0.0" width="375" height="667"/>
  39 + <autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
  40 + <subviews>
  41 + <tableView clipsSubviews="YES" contentMode="scaleToFill" misplaced="YES" alwaysBounceVertical="YES" dataMode="prototypes" style="plain" separatorStyle="default" rowHeight="44" sectionHeaderHeight="22" sectionFooterHeight="22" translatesAutoresizingMaskIntoConstraints="NO" id="pkt-yk-k7I">
  42 + <rect key="frame" x="0.0" y="0.0" width="320" height="568"/>
  43 + <color key="backgroundColor" red="1" green="1" blue="1" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
  44 + <connections>
  45 + <outlet property="dataSource" destination="JV9-zb-AoK" id="uKq-aW-3jU"/>
  46 + <outlet property="delegate" destination="JV9-zb-AoK" id="4KW-jx-X5j"/>
  47 + </connections>
  48 + </tableView>
  49 + </subviews>
  50 + <color key="backgroundColor" red="1" green="1" blue="1" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
  51 + <constraints>
  52 + <constraint firstItem="pkt-yk-k7I" firstAttribute="bottom" secondItem="CU9-WC-0d2" secondAttribute="top" id="31b-pL-b9A"/>
  53 + <constraint firstItem="pkt-yk-k7I" firstAttribute="top" secondItem="P2b-LU-zX2" secondAttribute="top" id="8lH-Xc-Tuq"/>
  54 + <constraint firstItem="pkt-yk-k7I" firstAttribute="leading" secondItem="P2b-LU-zX2" secondAttribute="leading" id="qx8-7m-R2z"/>
  55 + <constraint firstAttribute="trailing" secondItem="pkt-yk-k7I" secondAttribute="trailing" id="tHB-9K-Plq"/>
  56 + </constraints>
  57 + </view>
  58 + <navigationItem key="navigationItem" id="XIM-zK-Oz0"/>
  59 + <connections>
  60 + <segue destination="Q5u-Bp-ij9" kind="show" identifier="Service Identifier" id="0hx-FE-e5g"/>
  61 + <segue destination="6Xe-Tq-ihM" kind="show" identifier="Bucket Identifier" id="KXD-E3-zK9"/>
  62 + <segue destination="ueD-Uw-l9O" kind="show" identifier="Object Identifier" id="mAl-Su-1jo"/>
  63 + <segue destination="pAz-8E-add" kind="show" identifier="Perf Identifier" id="woA-O6-add"/>
  64 + </connections>
  65 + </viewController>
  66 + <placeholder placeholderIdentifier="IBFirstResponder" id="zCV-xv-RiG" userLabel="First Responder" sceneMemberID="firstResponder"/>
  67 + </objects>
  68 + <point key="canvasLocation" x="863" y="384"/>
  69 + </scene>
  70 + <!--List Bucket View Controller-->
  71 + <scene sceneID="OBL-3a-0co">
  72 + <objects>
  73 + <viewController id="QAl-kV-yE1" customClass="ListBucketViewController" sceneMemberID="viewController">
  74 + <layoutGuides>
  75 + <viewControllerLayoutGuide type="top" id="4bK-nn-E8L"/>
  76 + <viewControllerLayoutGuide type="bottom" id="MZL-D2-MAo"/>
  77 + </layoutGuides>
  78 + <view key="view" contentMode="scaleToFill" id="3z8-05-7lY">
  79 + <rect key="frame" x="0.0" y="0.0" width="375" height="667"/>
  80 + <autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
  81 + <subviews>
  82 + <tableView clipsSubviews="YES" contentMode="scaleToFill" fixedFrame="YES" alwaysBounceVertical="YES" dataMode="prototypes" style="plain" separatorStyle="default" rowHeight="44" sectionHeaderHeight="22" sectionFooterHeight="22" translatesAutoresizingMaskIntoConstraints="NO" id="pg4-3c-04Y">
  83 + <rect key="frame" x="0.0" y="0.0" width="320" height="568"/>
  84 + <autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
  85 + <color key="backgroundColor" red="1" green="1" blue="1" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
  86 + <connections>
  87 + <outlet property="dataSource" destination="QAl-kV-yE1" id="MxS-Gk-hAU"/>
  88 + <outlet property="delegate" destination="QAl-kV-yE1" id="2gF-e6-vfe"/>
  89 + </connections>
  90 + </tableView>
  91 + </subviews>
  92 + <color key="backgroundColor" red="1" green="1" blue="1" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
  93 + </view>
  94 + <connections>
  95 + <outlet property="bucketListTable" destination="pg4-3c-04Y" id="Sk0-k4-QLh"/>
  96 + </connections>
  97 + </viewController>
  98 + <placeholder placeholderIdentifier="IBFirstResponder" id="Ngr-GB-HzD" userLabel="First Responder" sceneMemberID="firstResponder"/>
  99 + </objects>
  100 + <point key="canvasLocation" x="1786" y="-80"/>
  101 + </scene>
  102 + <!--Service View Controller-->
  103 + <scene sceneID="uLw-ac-EoZ">
  104 + <objects>
  105 + <viewController id="Q5u-Bp-ij9" customClass="ServiceViewController" sceneMemberID="viewController">
  106 + <layoutGuides>
  107 + <viewControllerLayoutGuide type="top" id="jen-TV-RsB"/>
  108 + <viewControllerLayoutGuide type="bottom" id="EQh-x5-xoj"/>
  109 + </layoutGuides>
  110 + <view key="view" contentMode="scaleToFill" id="AdR-md-cLr">
  111 + <rect key="frame" x="0.0" y="0.0" width="375" height="667"/>
  112 + <autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
  113 + <subviews>
  114 + <tableView clipsSubviews="YES" contentMode="scaleToFill" fixedFrame="YES" alwaysBounceVertical="YES" dataMode="prototypes" style="plain" separatorStyle="default" rowHeight="44" sectionHeaderHeight="22" sectionFooterHeight="22" translatesAutoresizingMaskIntoConstraints="NO" id="oCf-DL-Tjh">
  115 + <rect key="frame" x="0.0" y="0.0" width="320" height="568"/>
  116 + <autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
  117 + <color key="backgroundColor" red="1" green="1" blue="1" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
  118 + <connections>
  119 + <outlet property="dataSource" destination="Q5u-Bp-ij9" id="EAZ-86-9mA"/>
  120 + <outlet property="delegate" destination="Q5u-Bp-ij9" id="YbJ-bn-faZ"/>
  121 + </connections>
  122 + </tableView>
  123 + </subviews>
  124 + <color key="backgroundColor" red="1" green="1" blue="1" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
  125 + </view>
  126 + <connections>
  127 + <segue destination="QAl-kV-yE1" kind="show" identifier="List Bucket Identifier" id="y5m-tz-H35"/>
  128 + </connections>
  129 + </viewController>
  130 + <placeholder placeholderIdentifier="IBFirstResponder" id="aR8-xQ-42N" userLabel="First Responder" sceneMemberID="firstResponder"/>
  131 + </objects>
  132 + <point key="canvasLocation" x="1352" y="-80"/>
  133 + </scene>
  134 + <!--Perf View Controller-->
  135 + <scene sceneID="Rhz-4j-yOH">
  136 + <objects>
  137 + <viewController id="pAz-8E-add" customClass="PerfViewController" sceneMemberID="viewController">
  138 + <layoutGuides>
  139 + <viewControllerLayoutGuide type="top" id="Ydn-zs-ghC"/>
  140 + <viewControllerLayoutGuide type="bottom" id="ZD1-EN-kVP"/>
  141 + </layoutGuides>
  142 + <view key="view" contentMode="scaleToFill" id="JHG-BN-xbh">
  143 + <rect key="frame" x="0.0" y="0.0" width="375" height="667"/>
  144 + <autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
  145 + <subviews>
  146 + <progressView opaque="NO" contentMode="scaleToFill" verticalHuggingPriority="750" progress="0.5" translatesAutoresizingMaskIntoConstraints="NO" id="laa-lK-2xH">
  147 + <rect key="frame" x="16" y="246.5" width="343" height="2"/>
  148 + <constraints>
  149 + <constraint firstAttribute="width" constant="343" id="WtX-l9-4Wo"/>
  150 + <constraint firstAttribute="height" constant="2" id="daY-GW-8hN"/>
  151 + </constraints>
  152 + </progressView>
  153 + <progressView opaque="NO" contentMode="scaleToFill" verticalHuggingPriority="750" progress="0.5" translatesAutoresizingMaskIntoConstraints="NO" id="DxO-Id-C4P">
  154 + <rect key="frame" x="16" y="311.5" width="343" height="2"/>
  155 + <constraints>
  156 + <constraint firstAttribute="height" constant="2" id="8oJ-Nw-MHo"/>
  157 + </constraints>
  158 + </progressView>
  159 + <label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="总体上传进度:" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="hIf-T3-bNL">
  160 + <rect key="frame" x="16" y="214" width="122" height="21"/>
  161 + <fontDescription key="fontDescription" type="system" pointSize="17"/>
  162 + <nil key="textColor"/>
  163 + <nil key="highlightedColor"/>
  164 + </label>
  165 + <label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="当前文件上传进度:" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="xZ0-F2-olh">
  166 + <rect key="frame" x="16" y="275.5" width="156" height="21"/>
  167 + <constraints>
  168 + <constraint firstAttribute="height" constant="21" id="PkA-zP-IfQ"/>
  169 + <constraint firstAttribute="width" constant="156" id="bj2-Rk-pPT"/>
  170 + </constraints>
  171 + <fontDescription key="fontDescription" type="system" pointSize="17"/>
  172 + <nil key="textColor"/>
  173 + <nil key="highlightedColor"/>
  174 + </label>
  175 + <button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="roundedRect" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="JJ5-eo-wOH">
  176 + <rect key="frame" x="297" y="72" width="62" height="30"/>
  177 + <state key="normal" title="开始上传"/>
  178 + <state key="disabled" title="正在上传"/>
  179 + <connections>
  180 + <action selector="startUpload:" destination="pAz-8E-add" eventType="touchUpInside" id="sym-HQ-NaA"/>
  181 + </connections>
  182 + </button>
  183 + <textField opaque="NO" clipsSubviews="YES" contentMode="scaleToFill" contentHorizontalAlignment="left" contentVerticalAlignment="center" text="1000" borderStyle="roundedRect" textAlignment="natural" minimumFontSize="17" translatesAutoresizingMaskIntoConstraints="NO" id="Cmt-XI-acJ">
  184 + <rect key="frame" x="111" y="72" width="114" height="30"/>
  185 + <constraints>
  186 + <constraint firstAttribute="width" constant="114" id="9We-Oc-WJv"/>
  187 + <constraint firstAttribute="height" constant="30" id="AWo-22-ylz"/>
  188 + </constraints>
  189 + <nil key="textColor"/>
  190 + <fontDescription key="fontDescription" type="system" pointSize="14"/>
  191 + <textInputTraits key="textInputTraits" keyboardType="numberPad"/>
  192 + </textField>
  193 + <label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="上传次数:" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="W8o-PI-7sJ">
  194 + <rect key="frame" x="16" y="77" width="87" height="21"/>
  195 + <fontDescription key="fontDescription" type="system" pointSize="17"/>
  196 + <nil key="textColor"/>
  197 + <nil key="highlightedColor"/>
  198 + </label>
  199 + <label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="200KB(70%) 5MB (20%) 12MB (10%)" textAlignment="center" lineBreakMode="tailTruncation" numberOfLines="4" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="nBB-XG-bgO">
  200 + <rect key="frame" x="16" y="116" width="343" height="90"/>
  201 + <constraints>
  202 + <constraint firstAttribute="height" constant="90" id="JDG-mz-FaU"/>
  203 + </constraints>
  204 + <fontDescription key="fontDescription" type="system" pointSize="17"/>
  205 + <nil key="textColor"/>
  206 + <nil key="highlightedColor"/>
  207 + </label>
  208 + <textView clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="scaleToFill" editable="NO" textAlignment="natural" selectable="NO" translatesAutoresizingMaskIntoConstraints="NO" id="jUM-7b-PvN">
  209 + <rect key="frame" x="16" y="352.5" width="343" height="294.5"/>
  210 + <color key="backgroundColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
  211 + <fontDescription key="fontDescription" type="system" pointSize="14"/>
  212 + <textInputTraits key="textInputTraits" autocapitalizationType="sentences"/>
  213 + </textView>
  214 + <label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="结果:" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="d4N-wH-H8i">
  215 + <rect key="frame" x="16" y="323.5" width="52" height="21"/>
  216 + <constraints>
  217 + <constraint firstAttribute="width" constant="52" id="Ie2-FW-puO"/>
  218 + <constraint firstAttribute="height" constant="21" id="KqC-nW-zch"/>
  219 + </constraints>
  220 + <fontDescription key="fontDescription" type="system" pointSize="17"/>
  221 + <nil key="textColor"/>
  222 + <nil key="highlightedColor"/>
  223 + </label>
  224 + </subviews>
  225 + <color key="backgroundColor" red="1" green="1" blue="1" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
  226 + <constraints>
  227 + <constraint firstItem="jUM-7b-PvN" firstAttribute="leading" secondItem="JHG-BN-xbh" secondAttribute="leadingMargin" id="0VE-wQ-PtU"/>
  228 + <constraint firstItem="JJ5-eo-wOH" firstAttribute="trailing" secondItem="JHG-BN-xbh" secondAttribute="trailingMargin" id="1EG-pY-0gA"/>
  229 + <constraint firstItem="xZ0-F2-olh" firstAttribute="top" secondItem="laa-lK-2xH" secondAttribute="bottom" constant="27" id="1PX-zU-DP6"/>
  230 + <constraint firstItem="hIf-T3-bNL" firstAttribute="top" secondItem="nBB-XG-bgO" secondAttribute="bottom" constant="8" id="1hH-8P-6VF"/>
  231 + <constraint firstItem="laa-lK-2xH" firstAttribute="top" secondItem="hIf-T3-bNL" secondAttribute="bottom" constant="11" id="79w-fX-BhF"/>
  232 + <constraint firstItem="W8o-PI-7sJ" firstAttribute="leading" secondItem="JHG-BN-xbh" secondAttribute="leadingMargin" id="ITE-Cb-fDK"/>
  233 + <constraint firstItem="Cmt-XI-acJ" firstAttribute="leading" secondItem="W8o-PI-7sJ" secondAttribute="trailing" constant="8" id="Jn8-pl-rrX"/>
  234 + <constraint firstItem="ZD1-EN-kVP" firstAttribute="top" secondItem="jUM-7b-PvN" secondAttribute="bottom" constant="20" id="Pif-ta-6h9"/>
  235 + <constraint firstItem="jUM-7b-PvN" firstAttribute="top" secondItem="d4N-wH-H8i" secondAttribute="bottom" constant="8" id="UAu-OF-4s0"/>
  236 + <constraint firstItem="d4N-wH-H8i" firstAttribute="leading" secondItem="JHG-BN-xbh" secondAttribute="leadingMargin" id="UZs-qp-2IN"/>
  237 + <constraint firstItem="jUM-7b-PvN" firstAttribute="trailing" secondItem="JHG-BN-xbh" secondAttribute="trailingMargin" id="Z8D-ss-QtK"/>
  238 + <constraint firstItem="hIf-T3-bNL" firstAttribute="leading" secondItem="JHG-BN-xbh" secondAttribute="leadingMargin" id="ZRz-xh-4xA"/>
  239 + <constraint firstItem="nBB-XG-bgO" firstAttribute="top" secondItem="Cmt-XI-acJ" secondAttribute="bottom" constant="14" id="Zbh-no-uaz"/>
  240 + <constraint firstItem="Cmt-XI-acJ" firstAttribute="top" secondItem="Ydn-zs-ghC" secondAttribute="bottom" constant="8" id="ZyS-tJ-8u3"/>
  241 + <constraint firstItem="d4N-wH-H8i" firstAttribute="top" secondItem="DxO-Id-C4P" secondAttribute="bottom" constant="10" id="a5H-dg-jBN"/>
  242 + <constraint firstItem="W8o-PI-7sJ" firstAttribute="top" secondItem="Ydn-zs-ghC" secondAttribute="bottom" constant="13" id="cWb-zh-klc"/>
  243 + <constraint firstItem="JJ5-eo-wOH" firstAttribute="top" secondItem="Ydn-zs-ghC" secondAttribute="bottom" constant="8" id="cfB-zK-wfA"/>
  244 + <constraint firstItem="xZ0-F2-olh" firstAttribute="leading" secondItem="JHG-BN-xbh" secondAttribute="leadingMargin" id="eb1-Fp-vyY"/>
  245 + <constraint firstItem="DxO-Id-C4P" firstAttribute="trailing" secondItem="JHG-BN-xbh" secondAttribute="trailingMargin" id="gZp-bz-ioJ"/>
  246 + <constraint firstItem="laa-lK-2xH" firstAttribute="trailing" secondItem="JHG-BN-xbh" secondAttribute="trailingMargin" id="gaT-Op-y3m"/>
  247 + <constraint firstItem="laa-lK-2xH" firstAttribute="leading" secondItem="JHG-BN-xbh" secondAttribute="leadingMargin" id="i6H-g1-sOa"/>
  248 + <constraint firstItem="DxO-Id-C4P" firstAttribute="leading" secondItem="JHG-BN-xbh" secondAttribute="leadingMargin" id="kI0-Uq-9gz"/>
  249 + <constraint firstItem="nBB-XG-bgO" firstAttribute="leading" secondItem="JHG-BN-xbh" secondAttribute="leadingMargin" id="qLZ-yU-xQz"/>
  250 + <constraint firstItem="DxO-Id-C4P" firstAttribute="top" secondItem="xZ0-F2-olh" secondAttribute="bottom" constant="15" id="yc9-oJ-IUr"/>
  251 + <constraint firstItem="nBB-XG-bgO" firstAttribute="trailing" secondItem="JHG-BN-xbh" secondAttribute="trailingMargin" id="zBm-pb-Erm"/>
  252 + </constraints>
  253 + </view>
  254 + <connections>
  255 + <outlet property="currentProgress" destination="DxO-Id-C4P" id="Qeg-Wr-U3D"/>
  256 + <outlet property="result" destination="jUM-7b-PvN" id="7wh-Xq-lXo"/>
  257 + <outlet property="startUploadButton" destination="JJ5-eo-wOH" id="n0u-Uq-lwC"/>
  258 + <outlet property="totalProgress" destination="laa-lK-2xH" id="CDa-1H-nOo"/>
  259 + <outlet property="uploadTimes" destination="Cmt-XI-acJ" id="TCp-bB-ceT"/>
  260 + </connections>
  261 + </viewController>
  262 + <placeholder placeholderIdentifier="IBFirstResponder" id="rBG-Uc-1aY" userLabel="First Responder" sceneMemberID="firstResponder"/>
  263 + </objects>
  264 + <point key="canvasLocation" x="640.79999999999995" y="1212.1439280359821"/>
  265 + </scene>
  266 + <!--Object View Controller-->
  267 + <scene sceneID="dxD-mh-JFF">
  268 + <objects>
  269 + <viewController id="ueD-Uw-l9O" customClass="ObjectViewController" sceneMemberID="viewController">
  270 + <layoutGuides>
  271 + <viewControllerLayoutGuide type="top" id="jie-V4-rh1"/>
  272 + <viewControllerLayoutGuide type="bottom" id="b1H-7Y-GCy"/>
  273 + </layoutGuides>
  274 + <view key="view" contentMode="scaleToFill" id="abN-ci-9iP">
  275 + <rect key="frame" x="0.0" y="0.0" width="375" height="667"/>
  276 + <autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
  277 + <subviews>
  278 + <tableView clipsSubviews="YES" contentMode="scaleToFill" misplaced="YES" alwaysBounceVertical="YES" dataMode="prototypes" style="plain" separatorStyle="default" rowHeight="44" sectionHeaderHeight="22" sectionFooterHeight="22" translatesAutoresizingMaskIntoConstraints="NO" id="e57-Cf-rdp">
  279 + <rect key="frame" x="0.0" y="0.0" width="320" height="568"/>
  280 + <color key="backgroundColor" red="1" green="1" blue="1" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
  281 + <connections>
  282 + <outlet property="dataSource" destination="ueD-Uw-l9O" id="6Y9-T1-kO7"/>
  283 + <outlet property="delegate" destination="ueD-Uw-l9O" id="ELh-5A-WZ9"/>
  284 + </connections>
  285 + </tableView>
  286 + </subviews>
  287 + <color key="backgroundColor" red="1" green="1" blue="1" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
  288 + <constraints>
  289 + <constraint firstItem="e57-Cf-rdp" firstAttribute="bottom" secondItem="b1H-7Y-GCy" secondAttribute="top" id="Avd-aD-H6p"/>
  290 + <constraint firstItem="e57-Cf-rdp" firstAttribute="top" secondItem="abN-ci-9iP" secondAttribute="top" id="MNg-QM-fdr"/>
  291 + <constraint firstAttribute="trailing" secondItem="e57-Cf-rdp" secondAttribute="trailing" id="NBi-in-hgB"/>
  292 + <constraint firstItem="e57-Cf-rdp" firstAttribute="leading" secondItem="abN-ci-9iP" secondAttribute="leading" id="lzJ-DZ-L4s"/>
  293 + </constraints>
  294 + </view>
  295 + </viewController>
  296 + <placeholder placeholderIdentifier="IBFirstResponder" id="wQE-c4-4jc" userLabel="First Responder" sceneMemberID="firstResponder"/>
  297 + </objects>
  298 + <point key="canvasLocation" x="1352" y="1246"/>
  299 + </scene>
  300 + <!--Get All Objects View Controller-->
  301 + <scene sceneID="EPc-YB-8VH">
  302 + <objects>
  303 + <viewController id="DoY-jf-EJI" customClass="GetAllObjectsViewController" sceneMemberID="viewController">
  304 + <layoutGuides>
  305 + <viewControllerLayoutGuide type="top" id="8Eu-cH-twq"/>
  306 + <viewControllerLayoutGuide type="bottom" id="U3B-3K-OdV"/>
  307 + </layoutGuides>
  308 + <view key="view" contentMode="scaleToFill" id="9Li-n3-WY4">
  309 + <rect key="frame" x="0.0" y="0.0" width="375" height="667"/>
  310 + <autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
  311 + <subviews>
  312 + <tableView clipsSubviews="YES" contentMode="scaleToFill" fixedFrame="YES" alwaysBounceVertical="YES" dataMode="prototypes" style="plain" separatorStyle="default" rowHeight="44" sectionHeaderHeight="22" sectionFooterHeight="22" translatesAutoresizingMaskIntoConstraints="NO" id="dbG-8H-vjx">
  313 + <rect key="frame" x="0.0" y="0.0" width="320" height="568"/>
  314 + <autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
  315 + <color key="backgroundColor" red="1" green="1" blue="1" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
  316 + <connections>
  317 + <outlet property="dataSource" destination="DoY-jf-EJI" id="UJr-t1-idb"/>
  318 + <outlet property="delegate" destination="DoY-jf-EJI" id="cZV-QT-oqX"/>
  319 + </connections>
  320 + </tableView>
  321 + </subviews>
  322 + <color key="backgroundColor" red="1" green="1" blue="1" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
  323 + </view>
  324 + <connections>
  325 + <outlet property="objectTable" destination="dbG-8H-vjx" id="dB4-gM-yEo"/>
  326 + </connections>
  327 + </viewController>
  328 + <placeholder placeholderIdentifier="IBFirstResponder" id="psc-md-V8U" userLabel="First Responder" sceneMemberID="firstResponder"/>
  329 + </objects>
  330 + <point key="canvasLocation" x="1794" y="1251"/>
  331 + </scene>
  332 + <!--Bucket View Controller-->
  333 + <scene sceneID="gZm-8m-23B">
  334 + <objects>
  335 + <viewController id="6Xe-Tq-ihM" customClass="BucketViewController" sceneMemberID="viewController">
  336 + <layoutGuides>
  337 + <viewControllerLayoutGuide type="top" id="Y6Q-af-w9d"/>
  338 + <viewControllerLayoutGuide type="bottom" id="RmB-0R-HVA"/>
  339 + </layoutGuides>
  340 + <view key="view" contentMode="scaleToFill" id="mPT-aN-zcn">
  341 + <rect key="frame" x="0.0" y="0.0" width="375" height="667"/>
  342 + <autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
  343 + <subviews>
  344 + <tableView clipsSubviews="YES" contentMode="scaleToFill" fixedFrame="YES" alwaysBounceVertical="YES" dataMode="prototypes" style="plain" separatorStyle="default" rowHeight="44" sectionHeaderHeight="22" sectionFooterHeight="22" translatesAutoresizingMaskIntoConstraints="NO" id="0YK-wN-Nch">
  345 + <rect key="frame" x="0.0" y="0.0" width="320" height="568"/>
  346 + <autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
  347 + <color key="backgroundColor" red="1" green="1" blue="1" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
  348 + <connections>
  349 + <outlet property="dataSource" destination="6Xe-Tq-ihM" id="L7l-Jb-Xr0"/>
  350 + <outlet property="delegate" destination="6Xe-Tq-ihM" id="4Rh-KT-95F"/>
  351 + </connections>
  352 + </tableView>
  353 + </subviews>
  354 + <color key="backgroundColor" red="1" green="1" blue="1" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
  355 + </view>
  356 + <connections>
  357 + <segue destination="Kol-Ij-ute" kind="show" identifier="Create Bucket Identifier" id="Keb-22-pgF"/>
  358 + <segue destination="DoY-jf-EJI" kind="show" identifier="Get All Objects In Bucket Identifier" id="Xai-LP-eT4"/>
  359 + </connections>
  360 + </viewController>
  361 + <placeholder placeholderIdentifier="IBFirstResponder" id="Wib-dg-trL" userLabel="First Responder" sceneMemberID="firstResponder"/>
  362 + </objects>
  363 + <point key="canvasLocation" x="1352" y="533"/>
  364 + </scene>
  365 + <!--Create Bucket View Controller-->
  366 + <scene sceneID="aXQ-As-ZAq">
  367 + <objects>
  368 + <viewController id="Kol-Ij-ute" customClass="CreateBucketViewController" sceneMemberID="viewController">
  369 + <layoutGuides>
  370 + <viewControllerLayoutGuide type="top" id="AVB-qo-4Zv"/>
  371 + <viewControllerLayoutGuide type="bottom" id="GfN-bQ-u1b"/>
  372 + </layoutGuides>
  373 + <view key="view" contentMode="scaleToFill" id="9ht-HA-bZi">
  374 + <rect key="frame" x="0.0" y="0.0" width="375" height="667"/>
  375 + <autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
  376 + <subviews>
  377 + <textField opaque="NO" clipsSubviews="YES" contentMode="scaleToFill" fixedFrame="YES" contentHorizontalAlignment="left" contentVerticalAlignment="center" borderStyle="roundedRect" minimumFontSize="17" translatesAutoresizingMaskIntoConstraints="NO" id="6Yn-Lh-oZQ">
  378 + <rect key="frame" x="16" y="89" width="288" height="30"/>
  379 + <autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
  380 + <fontDescription key="fontDescription" type="system" pointSize="14"/>
  381 + <textInputTraits key="textInputTraits"/>
  382 + </textField>
  383 + <button opaque="NO" contentMode="scaleToFill" fixedFrame="YES" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="roundedRect" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="F19-wp-jol">
  384 + <rect key="frame" x="16" y="127" width="288" height="30"/>
  385 + <autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
  386 + <state key="normal" title="Create">
  387 + <color key="titleShadowColor" red="0.5" green="0.5" blue="0.5" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
  388 + </state>
  389 + <connections>
  390 + <action selector="clickCreateBtn:" destination="Kol-Ij-ute" eventType="touchUpInside" id="EQ1-9t-T6C"/>
  391 + </connections>
  392 + </button>
  393 + </subviews>
  394 + <color key="backgroundColor" red="1" green="1" blue="1" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
  395 + </view>
  396 + <connections>
  397 + <outlet property="nameField" destination="6Yn-Lh-oZQ" id="Z3n-aA-Yhd"/>
  398 + </connections>
  399 + </viewController>
  400 + <placeholder placeholderIdentifier="IBFirstResponder" id="gxf-Ud-fLO" userLabel="First Responder" sceneMemberID="firstResponder"/>
  401 + <tableView clipsSubviews="YES" contentMode="scaleToFill" alwaysBounceVertical="YES" dataMode="prototypes" style="plain" separatorStyle="default" rowHeight="44" sectionHeaderHeight="22" sectionFooterHeight="22" id="hZN-v3-9aC">
  402 + <rect key="frame" x="0.0" y="0.0" width="320" height="568"/>
  403 + <autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
  404 + <color key="backgroundColor" red="1" green="1" blue="1" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
  405 + <connections>
  406 + <outlet property="dataSource" destination="ueD-Uw-l9O" id="0nV-mq-8vJ"/>
  407 + <outlet property="delegate" destination="ueD-Uw-l9O" id="KKi-T1-5SW"/>
  408 + </connections>
  409 + </tableView>
  410 + </objects>
  411 + <point key="canvasLocation" x="1786" y="533"/>
  412 + </scene>
  413 + </scenes>
  414 +</document>
... ...
KS3SDKDemo/KS3SDKDemo/BucketViewController.h 0 → 100755
  1 +//
  2 +// BucketViewController.h
  3 +// KS3iOSSDKDemo
  4 +//
  5 +// Created by Blues on 12/16/14.
  6 +// Copyright (c) 2014 Blues. All rights reserved.
  7 +//
  8 +
  9 +#import <UIKit/UIKit.h>
  10 +
  11 +@interface BucketViewController : UIViewController
  12 +
  13 +@end
... ...
KS3SDKDemo/KS3SDKDemo/BucketViewController.m 0 → 100755
  1 +//
  2 +// BucketViewController.m
  3 +// KS3iOSSDKDemo
  4 +//
  5 +// Created by Blues on 12/16/14.
  6 +// Copyright (c) 2014 Blues. All rights reserved.
  7 +//
  8 +
  9 +#warning Please set correct bucket name
  10 +#define kBucketName @"acc"
  11 +//#define kBucketName @"alert1"
  12 +
  13 +#import "BucketViewController.h"
  14 +#import <KS3YunSDK.h>
  15 +
  16 +#import "KS3Util.h"
  17 +#import <CNLiveUploadSDK/CNLiveUpload.h>
  18 +
  19 +@interface BucketViewController ()
  20 +
  21 +@property (nonatomic, strong) NSArray *arrItems;
  22 +
  23 +@end
  24 +
  25 +@implementation BucketViewController
  26 +
  27 +- (void)viewDidLoad
  28 +{
  29 + [super viewDidLoad];
  30 + self.navigationItem.title = @"Bucket";
  31 + _arrItems = [NSArray arrayWithObjects:
  32 + @"Create Bucket", @"Delete Bucket", @"Head Bucket",
  33 + @"Get Bucket ACL", @"Set Bucket ACL", @"Set Bucket Grant ACL",
  34 + @"Get Bucket Logging", @"Set Bucket Logging",
  35 + @"Get All Objects In Bucket", nil];
  36 +}
  37 +
  38 +#pragma mark - UITableView datasource
  39 +
  40 +- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
  41 +{
  42 + return _arrItems.count;
  43 +}
  44 +
  45 +- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
  46 +{
  47 + NSString *strIdentifier = @"bucket identifier";
  48 + UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:strIdentifier];
  49 + if (nil == cell) {
  50 + cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:strIdentifier];
  51 + }
  52 + cell.textLabel.text = _arrItems[indexPath.row];
  53 + return cell;
  54 +}
  55 +
  56 +#pragma mark - UITableView delegate
  57 +
  58 +- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
  59 +{
  60 + NSString *strIdentifier = @"";
  61 + switch (indexPath.row) {
  62 + case 0:
  63 + {
  64 + strIdentifier = @"Create Bucket Identifier";
  65 + [self performSegueWithIdentifier:strIdentifier sender:nil];
  66 + }
  67 + break;
  68 + case 1:
  69 + {
  70 + KS3DeleteBucketRequest *deleteBucketReq = [[KS3DeleteBucketRequest alloc] initWithName:@"1222"];
  71 + [deleteBucketReq setCompleteRequest];
  72 +
  73 + NSArray *array = [deleteBucketReq.kSYHeader componentsSeparatedByString:@"\n"];
  74 + NSString *headers = [array firstObject];
  75 + [CNLiveUpload getAuthDicWithMd5:deleteBucketReq.contentMd5 verb:deleteBucketReq.httpMethod type:deleteBucketReq.contentType res:deleteBucketReq.kSYResource headers:headers date:deleteBucketReq.strDate success:^(NSDictionary *dic) {
  76 + //使用token签名时从Appserver获取token后设置token,使用Ak sk则忽略,不需要调用
  77 + [deleteBucketReq setStrKS3Token:dic[@"Authorization"]];
  78 +
  79 + KS3DeleteBucketResponse *response = [[KS3Client initialize] deleteBucket:deleteBucketReq];
  80 + if (response.httpStatusCode == 204) { // **** 没有返回任何内容
  81 + NSLog(@"Delete bucket success!");
  82 + }
  83 + else {
  84 + NSLog(@"Delete bucket error: %@", response.error.description);
  85 + }
  86 + } failure:^(NSDictionary *error) {
  87 + NSLog(@"error %@",error);
  88 + }];
  89 + }
  90 + break;
  91 + case 2:
  92 + {
  93 + KS3HeadBucketRequest *headBucketReq = [[KS3HeadBucketRequest alloc] initWithName:kBucketName];
  94 + [headBucketReq setCompleteRequest];
  95 +
  96 + NSArray *array = [headBucketReq.kSYHeader componentsSeparatedByString:@"\n"];
  97 + NSString *headers = [array firstObject];
  98 + [CNLiveUpload getAuthDicWithMd5:headBucketReq.contentMd5 verb:headBucketReq.httpMethod type:headBucketReq.contentType res:headBucketReq.kSYResource headers:headers date:headBucketReq.strDate success:^(NSDictionary *dic) {
  99 + //使用token签名时从Appserver获取token后设置token,使用Ak sk则忽略,不需要调用
  100 + [headBucketReq setStrKS3Token:dic[@"Authorization"]];
  101 + KS3HeadBucketResponse *responsee = [[KS3Client initialize] headBucket:headBucketReq];
  102 + if (responsee.httpStatusCode == 200) {
  103 + NSLog(@"Head bucket success");
  104 + }
  105 + else {
  106 + NSLog(@"Head bucket error: %@", responsee.error.description);
  107 + }
  108 + }failure:^(NSDictionary *error) {
  109 + NSLog(@"error %@",error);
  110 + }];
  111 + }
  112 + break;
  113 + case 3:
  114 + {
  115 + KS3GetACLRequest *getBucketAclReq = [[KS3GetACLRequest alloc] initWithName:@"bjtest"];
  116 + [getBucketAclReq setCompleteRequest];
  117 +
  118 + NSArray *array = [getBucketAclReq.kSYHeader componentsSeparatedByString:@"\n"];
  119 + NSString *headers = [array firstObject];
  120 + [CNLiveUpload getAuthDicWithMd5:getBucketAclReq.contentMd5 verb:getBucketAclReq.httpMethod type:getBucketAclReq.contentType res:getBucketAclReq.kSYResource headers:headers date:getBucketAclReq.strDate success:^(NSDictionary *dic) {
  121 +
  122 + //使用token签名时从Appserver获取token后设置token,使用Ak sk则忽略,不需要调用
  123 + [getBucketAclReq setStrKS3Token:dic[@"Authorization"]];
  124 + KS3GetACLResponse *response = [[KS3Client initialize] getBucketACL:getBucketAclReq];
  125 + KS3BucketACLResult *result = response.listBucketsResult;
  126 + if (response.httpStatusCode == 200) {
  127 + NSLog(@"Get bucket acl success!");
  128 +
  129 + NSLog(@"Bucket owner ID: %@",result.owner.ID);
  130 + NSLog(@"Bucket owner displayName: %@",result.owner.displayName);
  131 +
  132 + for (KS3Grant *grant in result.accessControlList) {
  133 + NSLog(@"%@",grant.grantee.ID);
  134 + NSLog(@"%@",grant.grantee.displayName);
  135 + NSLog(@"%@",grant.grantee.URI);
  136 + NSLog(@"_______________________");
  137 + NSLog(@"%@",grant.permission);
  138 + }
  139 + }
  140 + else {
  141 + NSLog(@"Get bucket acl error: %@", response.error.description);
  142 + }
  143 +
  144 + }failure:^(NSDictionary *error) {
  145 + NSLog(@"error %@",error);
  146 + }];
  147 + }
  148 + break;
  149 + case 4:
  150 + {
  151 + KS3AccessControlList *acl = [[KS3AccessControlList alloc] init];
  152 + [acl setContronAccess:KingSoftYun_Permission_Public_Read];
  153 +// setBucketACLReq.acl = acl;
  154 + KS3SetACLRequest *setBucketACLReq = [[KS3SetACLRequest alloc] initWithName:kBucketName accessACL:acl];
  155 + [setBucketACLReq setCompleteRequest];
  156 +
  157 + NSArray *array = [setBucketACLReq.kSYHeader componentsSeparatedByString:@"\n"];
  158 + NSString *headers = [array firstObject];
  159 + [CNLiveUpload getAuthDicWithMd5:setBucketACLReq.contentMd5 verb:setBucketACLReq.httpMethod type:setBucketACLReq.contentType res:setBucketACLReq.kSYResource headers:headers date:setBucketACLReq.strDate success:^(NSDictionary *dic) {
  160 + //使用token签名时从Appserver获取token后设置token,使用Ak sk则忽略,不需要调用
  161 + [setBucketACLReq setStrKS3Token:dic[@"Authorization"]];
  162 + KS3SetACLResponse *response = [[KS3Client initialize] setBucketACL:setBucketACLReq];
  163 + NSLog(@"%@",[[NSString alloc] initWithData:response.body encoding:NSUTF8StringEncoding]);
  164 + if (response.httpStatusCode == 200) {
  165 + NSLog(@"Set bucket acl success!");
  166 + }
  167 + else {
  168 + NSLog(@"Set bucket acl error: %@", response.error.description);
  169 + }
  170 + }failure:^(NSDictionary *error) {
  171 + NSLog(@"error %@",error);
  172 + }];
  173 + }
  174 + break;
  175 + case 5:
  176 + {
  177 + KS3GrantAccessControlList *acl = [[KS3GrantAccessControlList alloc] init];
  178 + acl.identifier = @"4567894346";
  179 + acl.displayName = @"accDisplayName";
  180 + [acl setGrantControlAccess:KingSoftYun_Grant_Permission_Read];
  181 +
  182 + KS3SetGrantACLRequest *setGrantACLRequest = [[KS3SetGrantACLRequest alloc] initWithName:kBucketName accessACL:acl];
  183 + [setGrantACLRequest setCompleteRequest];
  184 +
  185 + NSArray *array = [setGrantACLRequest.kSYHeader componentsSeparatedByString:@"\n"];
  186 + NSString *headers = [array firstObject];
  187 + [CNLiveUpload getAuthDicWithMd5:setGrantACLRequest.contentMd5 verb:setGrantACLRequest.httpMethod type:setGrantACLRequest.contentType res:setGrantACLRequest.kSYResource headers:headers date:setGrantACLRequest.strDate success:^(NSDictionary *dic) {
  188 + //使用token签名时从Appserver获取token后设置token,使用Ak sk则忽略,不需要调用
  189 + [setGrantACLRequest setStrKS3Token:dic[@"Authorization"]];
  190 + KS3SetGrantACLResponse *response = [[KS3Client initialize] setGrantACL:setGrantACLRequest];
  191 + if (response.httpStatusCode == 200) {
  192 + NSLog(@"Set bucket grant acl success!");
  193 + }
  194 + else {
  195 + NSLog(@"Set bucket grant acl error: %@", response.error.description);
  196 + }
  197 + }failure:^(NSDictionary *error) {
  198 + NSLog(@"error %@",error);
  199 + }];
  200 + }
  201 + break;
  202 + case 6:
  203 + {
  204 + KS3GetBucketLoggingRequest *getBucketLoggingReq = [[KS3GetBucketLoggingRequest alloc] initWithName:kBucketName];
  205 + [getBucketLoggingReq setCompleteRequest];
  206 +
  207 + NSArray *array = [getBucketLoggingReq.kSYHeader componentsSeparatedByString:@"\n"];
  208 + NSString *headers = [array firstObject];
  209 + [CNLiveUpload getAuthDicWithMd5:getBucketLoggingReq.contentMd5 verb:getBucketLoggingReq.httpMethod type:getBucketLoggingReq.contentType res:getBucketLoggingReq.kSYResource headers:headers date:getBucketLoggingReq.strDate success:^(NSDictionary *dic) {
  210 + //使用token签名时从Appserver获取token后设置token,使用Ak sk则忽略,不需要调用
  211 + [getBucketLoggingReq setStrKS3Token:dic[@"Authorization"]];
  212 +
  213 + KS3GetBucketLoggingResponse *response = [[KS3Client initialize] getBucketLogging:getBucketLoggingReq];
  214 + if (response.httpStatusCode == 200) {
  215 + NSLog(@"Get bucket logging success!");
  216 + }
  217 + else {
  218 + NSLog(@"Get bucket logging error: %@", response.error.description);
  219 + }
  220 + }failure:^(NSDictionary *error) {
  221 + NSLog(@"error %@",error);
  222 + }];
  223 + }
  224 + break;
  225 + case 7:
  226 + {
  227 + NSLog(@"移动端暂不支持");
  228 + }
  229 + break;
  230 + case 8:
  231 + strIdentifier = @"Get All Objects In Bucket Identifier";
  232 + [self performSegueWithIdentifier:strIdentifier sender:nil];
  233 + break;
  234 + default:
  235 + break;
  236 + }
  237 +}
  238 +
  239 +
  240 +@end
... ...
KS3SDKDemo/KS3SDKDemo/CNLiveCommonTools.h 0 → 100644
  1 +//
  2 +// CNLiveCommonTools.h
  3 +// KS3SDKDemo
  4 +//
  5 +// Created by 张旭 on 2017/8/7.
  6 +// Copyright © 2017年 Kingsoft. All rights reserved.
  7 +//
  8 +
  9 +#import <Foundation/Foundation.h>
  10 +
  11 +@interface CNLiveCommonTools : NSObject
  12 +//SHA加密
  13 ++ (NSMutableDictionary *)ksencryptionSignWithParameter:(NSMutableDictionary *)parameter;
  14 +
  15 ++ (NSString*)kssha1:(NSString *)string;
  16 +
  17 ++ (NSString *)kssignvalue:(NSDictionary*)parameter;
  18 +
  19 +//获取真实时间
  20 ++ (void)ksgetRealTimeString:(void(^)(NSString *timeString, NSDate *date))realTime;
  21 +
  22 +//获取MD5
  23 ++ (NSString*)ksrd_getFileMD5WithPath:(NSString*)path;
  24 +@end
... ...
KS3SDKDemo/KS3SDKDemo/CNLiveCommonTools.m 0 → 100644
  1 +//
  2 +// CNLiveCommonTools.m
  3 +// KS3SDKDemo
  4 +//
  5 +// Created by 张旭 on 2017/8/7.
  6 +// Copyright © 2017年 Kingsoft. All rights reserved.
  7 +//
  8 +
  9 +#import "CNLiveCommonTools.h"
  10 +
  11 +#import "CommonCrypto/CommonDigest.h"
  12 +#import <UIKit/UIKit.h>
  13 +#import "AppDelegate.h"
  14 +
  15 +#define CNLiveFileHashDefaultChunkSizeForReadingData 1024*8
  16 +
  17 +@implementation CNLiveCommonTools
  18 ++ (NSMutableDictionary *)ksencryptionSignWithParameter:(NSMutableDictionary *)parameter
  19 +{
  20 + NSString *string = [NSString stringWithFormat:@"%@&key=%@",[self kssignvalue:parameter],AppKey];
  21 + NSString *signString = [[self kssha1:string] uppercaseString];
  22 + NSMutableDictionary *startPara = [NSMutableDictionary dictionaryWithDictionary:parameter];
  23 + [startPara setObject:signString forKey:@"sign"];
  24 + return startPara;
  25 +}
  26 +
  27 ++ (NSString*)kssha1:(NSString *)string
  28 +{
  29 + NSData *data = [string dataUsingEncoding:NSUTF8StringEncoding];
  30 +
  31 + uint8_t digest[CC_SHA1_DIGEST_LENGTH];
  32 +
  33 + CC_SHA1(data.bytes, data.length, digest);
  34 +
  35 + NSMutableString* output = [NSMutableString stringWithCapacity:CC_SHA1_DIGEST_LENGTH * 2];
  36 +
  37 + for(int i = 0; i < CC_SHA1_DIGEST_LENGTH; i++)
  38 + [output appendFormat:@"%02x", digest[i]];
  39 +
  40 + while ([[output substringToIndex:1] isEqualToString:@"0"]) {
  41 + output = [[NSMutableString alloc] initWithString:[output substringFromIndex:1]];
  42 + }
  43 +
  44 + return output;
  45 +}
  46 +
  47 ++ (NSString *)kssignvalue:(NSDictionary*)parameter
  48 +{
  49 + //对所有传入参数按照字段名的 ASCII 码从小到大排序
  50 + NSArray *keyArr=[parameter allKeys];
  51 + NSArray *arr = [keyArr sortedArrayUsingSelector:@selector(compare:)];
  52 +
  53 + NSMutableString *string1 = [[NSMutableString alloc]init];
  54 + for (int i=0; i<arr.count; i++) {
  55 +
  56 + NSString *parameterString = parameter[[arr objectAtIndex:i]];
  57 + if (parameterString.length > 0) {
  58 + [string1 appendString:[NSString stringWithFormat:@"%@=%@&",[arr objectAtIndex:i],parameter[[arr objectAtIndex:i]]]];
  59 + }
  60 + }
  61 +
  62 + if (string1.length > 0) {
  63 + [string1 deleteCharactersInRange:NSMakeRange(string1.length-1, 1)];
  64 + }
  65 +
  66 + return string1;
  67 +}
  68 +
  69 +//获取真实时间
  70 ++ (void)ksgetRealTimeString:(void(^)(NSString *timeString, NSDate *date))realTime
  71 +{
  72 + [NSURLConnection sendAsynchronousRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:@"https://m.baidu.com"]] queue:[[NSOperationQueue alloc] init] completionHandler:^(NSURLResponse * _Nullable response, NSData * _Nullable data, NSError * _Nullable connectionError) {
  73 +
  74 + if (!response) {
  75 + NSDate *curDate = [NSDate date];
  76 + NSInteger time = [curDate timeIntervalSince1970];
  77 + NSString *timeString = [NSString stringWithFormat:@"%ld", (long)time];
  78 + dispatch_sync(dispatch_get_main_queue(), ^{
  79 + realTime(timeString, curDate);
  80 + });
  81 + return ;
  82 + }
  83 +
  84 + NSHTTPURLResponse *httpResponse = (NSHTTPURLResponse *)response;
  85 + NSString *timestamp = [[httpResponse allHeaderFields] objectForKey:@"Date"];
  86 +
  87 + NSString *timeStr = [timestamp substringWithRange:NSMakeRange(5, 20)];
  88 + NSDateFormatter *formatter = [[NSDateFormatter alloc] init];
  89 + NSTimeZone *timeZone = [NSTimeZone timeZoneWithName:@"GMT"];
  90 + NSLocale *local = [[NSLocale alloc]initWithLocaleIdentifier:@"en_US_POSIX"];
  91 + [formatter setLocale:local];//需要配置区域,不然会造成模拟器正常,真机日期为null的情况
  92 + [formatter setTimeZone:timeZone];
  93 + [formatter setDateFormat:@"dd MMM yyyy HH:mm:ss"];//设置源时间字符串的格式
  94 + NSDate *date = [formatter dateFromString:timeStr];//将源时间字符串转化为NSDate
  95 +
  96 + NSString *timeString = [NSString stringWithFormat:@"%.0f", [date timeIntervalSince1970]];
  97 + dispatch_sync(dispatch_get_main_queue(), ^{
  98 + realTime(timeString, date);
  99 + });
  100 + }];
  101 +}
  102 +
  103 +//获取MD5
  104 ++ (NSString*)ksrd_getFileMD5WithPath:(NSString*)path
  105 +{
  106 + return (__bridge_transfer NSString *)FileMD5HashCreateWithPath((__bridge CFStringRef)path, CNLiveFileHashDefaultChunkSizeForReadingData);
  107 +}
  108 +
  109 +CFStringRef FileMD5HashCreateWithPath(CFStringRef filePath,size_t chunkSizeForReadingData) {
  110 + // Declare needed variables
  111 + CFStringRef result = NULL;
  112 + CFReadStreamRef readStream = NULL;
  113 + // Get the file URL
  114 + CFURLRef fileURL =
  115 + CFURLCreateWithFileSystemPath(kCFAllocatorDefault,
  116 + (CFStringRef)filePath,
  117 + kCFURLPOSIXPathStyle,
  118 + (Boolean)false);
  119 + if (!fileURL) goto done;
  120 + // Create and open the read stream
  121 + readStream = CFReadStreamCreateWithFile(kCFAllocatorDefault,
  122 + (CFURLRef)fileURL);
  123 + if (!readStream) goto done;
  124 + bool didSucceed = (bool)CFReadStreamOpen(readStream);
  125 + if (!didSucceed) goto done;
  126 + // Initialize the hash object
  127 + CC_MD5_CTX hashObject;
  128 + CC_MD5_Init(&hashObject);
  129 + // Make sure chunkSizeForReadingData is valid
  130 + if (!chunkSizeForReadingData) {
  131 + chunkSizeForReadingData = CNLiveFileHashDefaultChunkSizeForReadingData;
  132 + }
  133 + // Feed the data to the hash object
  134 + bool hasMoreData = true;
  135 + while (hasMoreData) {
  136 + uint8_t buffer[chunkSizeForReadingData];
  137 + CFIndex readBytesCount = CFReadStreamRead(readStream,(UInt8 *)buffer,(CFIndex)sizeof(buffer));
  138 + if (readBytesCount == -1) break;
  139 + if (readBytesCount == 0) {
  140 + hasMoreData = false;
  141 + continue;
  142 + }
  143 + CC_MD5_Update(&hashObject,(const void *)buffer,(CC_LONG)readBytesCount);
  144 + }
  145 + // Check if the read operation succeeded
  146 + didSucceed = !hasMoreData;
  147 + // Compute the hash digest
  148 + unsigned char digest[CC_MD5_DIGEST_LENGTH];
  149 + CC_MD5_Final(digest, &hashObject);
  150 + // Abort if the read operation failed
  151 + if (!didSucceed) goto done;
  152 + // Compute the string result
  153 + char hash[2 * sizeof(digest) + 1];
  154 + for (size_t i = 0; i < sizeof(digest); ++i) {
  155 + snprintf(hash + (2 * i), 3, "%02x", (int)(digest[i]));
  156 + }
  157 + result = CFStringCreateWithCString(kCFAllocatorDefault,(const char *)hash,kCFStringEncodingUTF8);
  158 +
  159 +done:
  160 + if (readStream) {
  161 + CFReadStreamClose(readStream);
  162 + CFRelease(readStream);
  163 + }
  164 + if (fileURL) {
  165 + CFRelease(fileURL);
  166 + }
  167 + return result;
  168 +}
  169 +@end
... ...
KS3SDKDemo/KS3SDKDemo/CNLiveNetManager.h 0 → 100644
  1 +//
  2 +// CNLiveNetManager.h
  3 +// KS3SDKDemo
  4 +//
  5 +// Created by 张旭 on 2017/8/7.
  6 +// Copyright © 2017年 Kingsoft. All rights reserved.
  7 +//
  8 +
  9 +#import <Foundation/Foundation.h>
  10 +
  11 +@interface CNLiveNetManager : NSObject
  12 +/**
  13 + * 设置超时时间
  14 + */
  15 +@property (nonatomic, assign) NSTimeInterval timeoutInterval;
  16 +
  17 +/**
  18 + * 缓存策略
  19 + */
  20 +@property (nonatomic, assign) NSURLRequestCachePolicy cachePolicy;
  21 +
  22 ++ (nonnull CNLiveNetManager *)manager;
  23 +
  24 +/**
  25 + * GET 请求
  26 + * @param URL
  27 + * @param parameters 上传参数
  28 + * @param success 请求成功回调
  29 + * @param failure 请求失败回调
  30 + */
  31 +- (void)requestGetURL:(nullable NSString *)URL
  32 + parameters:(nullable NSDictionary *)parameters
  33 + success:(nullable void (^)(NSURLResponse *_Nullable response, id _Nullable responseObject))success
  34 + failure:(nullable void (^)(NSURLResponse *_Nullable response, NSError *_Nullable error))failure;
  35 +
  36 +/**
  37 + * POST 请求
  38 + * @param URL
  39 + * @param parameters 上传参数
  40 + * @param success 请求成功回调
  41 + * @param failure 请求失败回调
  42 + */
  43 +- (void)requestPostURL:(nullable NSString *)URL
  44 + parameters:(nullable NSDictionary *)parameters
  45 + success:(nullable void (^)(NSURLResponse *_Nullable response, id _Nullable responseObject))success
  46 + failure:(nullable void (^)(NSURLResponse *_Nullable response, NSError *_Nullable error))failure;
  47 +
  48 +
  49 +/**
  50 + * 用于获取播放地址
  51 + */
  52 +- (void)requestGetVideoURL:(nullable NSString *)URL
  53 + success:(nullable void (^)(NSString *_Nullable videoURL))success;
  54 +
  55 +
  56 +- (void)destroyNetManager;
  57 +@end
... ...
KS3SDKDemo/KS3SDKDemo/CNLiveNetManager.m 0 → 100644
  1 +//
  2 +// CNLiveNetManager.m
  3 +// KS3SDKDemo
  4 +//
  5 +// Created by 张旭 on 2017/8/7.
  6 +// Copyright © 2017年 Kingsoft. All rights reserved.
  7 +//
  8 +
  9 +#import "CNLiveNetManager.h"
  10 +#import "CNLiveReqSerialization.h"
  11 +/**
  12 + * 网络超时时间 默认 60
  13 + */
  14 +static NSTimeInterval TimeoutInterval = 30.0 ;
  15 +
  16 +/**
  17 + * 缓存策略
  18 + * NSURLRequestUseProtocolCachePolicy // 默认的缓存策略(取决于协议)
  19 + * NSURLRequestReloadIgnoringLocalCacheData // 忽略缓存,重新请求
  20 + * NSURLRequestReloadIgnoringLocalAndRemoteCacheData // 未实现
  21 + * NSURLRequestReloadIgnoringCacheData = NSURLRequestReloadIgnoringLocalCacheData // 忽略缓存,重新请求
  22 + * NSURLRequestReturnCacheDataElseLoad// 有缓存就用缓存,忽略过期时间!没有缓存就重新请求
  23 + * NSURLRequestReturnCacheDataDontLoad// 有缓存就用缓存,没有缓存就不发请求,当做请求出错处理(用于离线模式)
  24 + * NSURLRequestReloadRevalidatingCacheData // 未实现
  25 + */
  26 +static NSURLRequestCachePolicy CachePolicy = NSURLRequestUseProtocolCachePolicy;
  27 +
  28 +typedef void(^GetVideoURLSuccessBlock)(NSString *_Nullable videoURL);
  29 +
  30 +@interface CNLiveNetManager ()<NSURLSessionDelegate>
  31 +{
  32 + BOOL _result;
  33 +}
  34 +
  35 +@property (nonatomic, copy) GetVideoURLSuccessBlock successBlock;
  36 +
  37 +@end
  38 +
  39 +@implementation CNLiveNetManager
  40 +
  41 +- (void)dealloc
  42 +{
  43 + // D_NSLog(@">>>>>>>>>>>>>> CNLiveKSYNetworkManager dealloc");
  44 +}
  45 +
  46 +- (void)destroyNetManager {
  47 + self.successBlock = nil;
  48 + // D_NSLog(@">>>>>>>>>>>>>> destroyNetManager");
  49 +
  50 +}
  51 +
  52 ++ (CNLiveNetManager *)manager
  53 +{
  54 + static CNLiveNetManager *manager = nil;
  55 +
  56 + static dispatch_once_t predicate;
  57 +
  58 + dispatch_once(&predicate, ^{
  59 +
  60 + manager = [[CNLiveNetManager alloc] init];
  61 +
  62 + });
  63 +
  64 + manager.cachePolicy = CachePolicy;
  65 +
  66 + manager.timeoutInterval = TimeoutInterval;
  67 +
  68 + return manager;
  69 +}
  70 +
  71 +- (instancetype)init
  72 +{
  73 + self = [super init];
  74 + if (self) {
  75 + self.cachePolicy = CachePolicy;
  76 + self.timeoutInterval = TimeoutInterval;
  77 + }
  78 + return self;
  79 +}
  80 +
  81 +-(void)requestGetURL:(NSString *)URL
  82 + parameters:(NSDictionary *)parameters
  83 + success:(void (^)(NSURLResponse * _Nullable, id _Nullable))success
  84 + failure:(void (^)(NSURLResponse * _Nullable, NSError * _Nullable))failure
  85 +{
  86 + NSURLSessionDataTask *task = [self dataTaskWithRequestMethod:@"GET" URLString:URL parameters:parameters success:success failure:failure];
  87 + [task resume];
  88 +}
  89 +
  90 +- (void)requestPostURL:(NSString *)URL
  91 + parameters:(NSDictionary *)parameters
  92 + success:(void (^)(NSURLResponse * _Nullable, id _Nullable))success
  93 + failure:(void (^)(NSURLResponse * _Nullable, NSError * _Nullable))failure
  94 +{
  95 + NSURLSessionDataTask *task = [self dataTaskWithRequestMethod:@"POST" URLString:URL parameters:parameters success:success failure:failure];
  96 + [task resume];
  97 +}
  98 +
  99 +- (void)requestGetVideoURL:(NSString *)URL success:(void (^)(NSString * _Nullable))success {
  100 +
  101 + self.successBlock = success;
  102 + _result = NO;
  103 +
  104 + NSURLSessionConfiguration *sessionConfig = [NSURLSessionConfiguration defaultSessionConfiguration];
  105 +
  106 + NSURLSession *session = [NSURLSession sessionWithConfiguration:sessionConfig
  107 + delegate:self
  108 + delegateQueue:[[NSOperationQueue alloc] init]];
  109 +
  110 + NSMutableURLRequest *request = [[NSMutableURLRequest alloc] initWithURL:[NSURL URLWithString:URL] cachePolicy:self.cachePolicy timeoutInterval:self.timeoutInterval];
  111 +
  112 + NSURLSessionDataTask *task = [session dataTaskWithRequest:request];
  113 +
  114 + // 启动任务
  115 + [task resume];
  116 +}
  117 +
  118 +#pragma mark -
  119 +#pragma mark - NSURLSessionDelegate
  120 +// 1.接收到服务器的响应
  121 +- (void)URLSession:(NSURLSession *)session dataTask:(NSURLSessionDataTask *)dataTask didReceiveResponse:(NSURLResponse *)response completionHandler:(void (^)(NSURLSessionResponseDisposition))completionHandler {
  122 + // 允许处理服务器的响应,才会继续接收服务器返回的数据
  123 + completionHandler(NSURLSessionResponseCancel);
  124 + _result = YES;
  125 + self.successBlock([response.URL absoluteString]);
  126 +
  127 +}
  128 +
  129 +// 3.请求成功或者失败(如果失败,error有值)
  130 +- (void)URLSession:(NSURLSession *)session task:(NSURLSessionTask *)task didCompleteWithError:(NSError *)error {
  131 + // 请求完成,成功或者失败的处理
  132 +
  133 + if (_result) return;
  134 +
  135 + NSString *videoUrl302 = error.userInfo[@"NSErrorFailingURLStringKey"];
  136 + if (!videoUrl302 || ![videoUrl302 isKindOfClass:[NSString class]] || videoUrl302.length <= 0) {
  137 + videoUrl302 = nil;
  138 + }
  139 + self.successBlock(videoUrl302);
  140 +
  141 +}
  142 +
  143 +
  144 +- (NSURLSessionDataTask *)dataTaskWithRequestMethod:(NSString *)method
  145 + URLString:(NSString *)URLString
  146 + parameters:(NSDictionary *)parameters
  147 + success:(void (^)(NSURLResponse * _Nullable, id _Nullable))success
  148 + failure:(void (^)(NSURLResponse * _Nullable, NSError * _Nullable))failure
  149 +{
  150 +
  151 + if (![URLString isKindOfClass:[NSString class]]) {
  152 + NSError *error = [NSError errorWithDomain:NSURLErrorDomain code:-1 userInfo:@{NSLocalizedDescriptionKey : @"please enter a valid url"}];
  153 + failure(nil, error);
  154 + return nil;
  155 + }
  156 +
  157 + NSString *newURLString;
  158 + if ([method isEqualToString:@"GET"]) {
  159 + if (parameters) {
  160 + newURLString = [[URLString stringByAppendingString:@"?"] stringByAppendingString:[CNLiveReqSerialization CNLiveQueryStringFromParameters:parameters]];
  161 + }else{
  162 + newURLString = URLString;
  163 + }
  164 + }else{
  165 + newURLString = URLString;
  166 + }
  167 +
  168 + NSMutableURLRequest *request = [[NSMutableURLRequest alloc] initWithURL:[NSURL URLWithString:newURLString] cachePolicy:self.cachePolicy timeoutInterval:self.timeoutInterval];
  169 +
  170 + request.HTTPMethod = method;
  171 +
  172 + if([method isEqual:@"POST"]){
  173 + [request addValue:@"application/x-www-form-urlencoded" forHTTPHeaderField:@"Content-Type"];
  174 + request.HTTPBody =[[CNLiveReqSerialization CNLiveQueryStringFromParameters:parameters] dataUsingEncoding:NSUTF8StringEncoding];
  175 + }
  176 +
  177 + NSURLSessionDataTask *task = [self dataTaskWithRequest:request success:success failure:failure];
  178 +
  179 + return task;
  180 +}
  181 +
  182 +- (NSURLSessionDataTask *)dataTaskWithRequest:(NSURLRequest *)request
  183 + success:(void (^)(NSURLResponse * _Nullable, id _Nullable))success
  184 + failure:(void (^)(NSURLResponse * _Nullable, NSError * _Nullable))failure
  185 +{
  186 + NSURLSession *session = [NSURLSession sharedSession];
  187 + NSURLSessionDataTask *task = [session dataTaskWithRequest:request completionHandler:^(NSData * _Nullable data, NSURLResponse * _Nullable response, NSError * _Nullable error) {
  188 +
  189 + dispatch_async(dispatch_get_main_queue(), ^{
  190 + if (error) {
  191 + failure(response,error);
  192 + }else{
  193 + if ([response isKindOfClass:[NSHTTPURLResponse class]]) {
  194 + NSHTTPURLResponse *httpResponse = (NSHTTPURLResponse *)response;
  195 + if (httpResponse.statusCode < 400) {
  196 + id jsonObj = [NSJSONSerialization JSONObjectWithData:data options:NSJSONReadingMutableContainers error:nil];
  197 + success(httpResponse,jsonObj);
  198 + } else {
  199 + NSError *failureError = [NSError errorWithDomain:NSURLErrorDomain code:httpResponse.statusCode userInfo:httpResponse.allHeaderFields];
  200 + failure(httpResponse,failureError);
  201 + }
  202 + } else {
  203 + failure(response,error);
  204 + }
  205 + }
  206 + });
  207 + }];
  208 +
  209 + return task;
  210 +}
  211 +
  212 +- (NSURL *)formatURLString:(NSString *)url
  213 +{
  214 + NSURL *urlString = [NSURL URLWithString:[url stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceCharacterSet]]];
  215 + return urlString;
  216 +}
  217 +@end
... ...
KS3SDKDemo/KS3SDKDemo/CNLiveReqSerialization.h 0 → 100644
  1 +//
  2 +// CNLiveReqSerialization.h
  3 +// KS3SDKDemo
  4 +//
  5 +// Created by 张旭 on 2017/8/7.
  6 +// Copyright © 2017年 Kingsoft. All rights reserved.
  7 +//
  8 +
  9 +#import <Foundation/Foundation.h>
  10 +
  11 +@interface CNLiveReqSerialization : NSObject
  12 ++ (nullable NSString *)CNLiveQueryStringFromParameters:(nullable NSDictionary *)parameters;
  13 +
  14 +@end
... ...
KS3SDKDemo/KS3SDKDemo/CNLiveReqSerialization.m 0 → 100644
  1 +//
  2 +// CNLiveReqSerialization.m
  3 +// KS3SDKDemo
  4 +//
  5 +// Created by 张旭 on 2017/8/7.
  6 +// Copyright © 2017年 Kingsoft. All rights reserved.
  7 +//
  8 +
  9 +#import "CNLiveReqSerialization.h"
  10 +
  11 +@interface CNLiveReqSerialization ()
  12 +
  13 +@property (readwrite, nonatomic, strong) id value;
  14 +
  15 +@property (readwrite, nonatomic, strong) id field;
  16 +
  17 +@end
  18 +
  19 +@implementation CNLiveReqSerialization
  20 +
  21 +- (id)initWithField:(id)field value:(id)value
  22 +{
  23 + self = [super init];
  24 +
  25 + if (self) {
  26 +
  27 + self.field = field;
  28 +
  29 + self.value = value;
  30 + }
  31 +
  32 + return self;
  33 +
  34 +}
  35 +
  36 +#pragma mark -
  37 +
  38 +FOUNDATION_EXPORT NSArray * CNLiveQueryStringPairsFromDictionary(NSDictionary *dictionary);
  39 +FOUNDATION_EXPORT NSArray * CNLiveQueryStringPairsFromKeyAndValue(NSString *key, id value);
  40 +
  41 ++ (NSString *)CNLiveQueryStringFromParameters:(NSDictionary *)parameters
  42 +{
  43 + NSMutableArray *mutablePairs = [NSMutableArray array];
  44 + for (CNLiveReqSerialization *pair in CNLiveQueryStringPairsFromDictionary(parameters)) {
  45 + [mutablePairs addObject:[pair URLEncodedStringValue]];
  46 + }
  47 + return [mutablePairs componentsJoinedByString:@"&"];
  48 +}
  49 +
  50 +NSArray * CNLiveQueryStringPairsFromDictionary(NSDictionary *dictionary)
  51 +{
  52 + return CNLiveQueryStringPairsFromKeyAndValue(nil, dictionary);
  53 +}
  54 +
  55 +/**
  56 + * 处理上传参数
  57 + */
  58 +NSArray * CNLiveQueryStringPairsFromKeyAndValue(NSString *key, id value)
  59 +{
  60 + NSMutableArray *mutableQueryStringComponents = [NSMutableArray array];
  61 +
  62 + //排序方式
  63 + NSSortDescriptor *sortDescriptor = [NSSortDescriptor sortDescriptorWithKey:@"description" ascending:YES selector:@selector(compare:)];
  64 +
  65 + if ([value isKindOfClass:[NSDictionary class]]) { //字典
  66 + NSDictionary *dictionary = value;
  67 + for (id nestedKey in [dictionary.allKeys sortedArrayUsingDescriptors:@[sortDescriptor]]) {
  68 + id nestedValue = dictionary[nestedKey];
  69 + if (nestedKey) {
  70 + [mutableQueryStringComponents addObjectsFromArray:CNLiveQueryStringPairsFromKeyAndValue((key ? [NSString stringWithFormat:@"%@[%@]", key, nestedKey] : nestedKey), nestedValue)];
  71 + }
  72 + }
  73 + }
  74 +
  75 + else if ([value isKindOfClass:[NSArray class]]){ //数组
  76 + NSArray *array = value;
  77 + for (id nestedValue in array) {
  78 + [mutableQueryStringComponents addObjectsFromArray:CNLiveQueryStringPairsFromKeyAndValue([NSString stringWithFormat:@"%@[]", key], nestedValue)];
  79 + }
  80 + }else if ([value isKindOfClass:[NSSet class]]){ //集合
  81 + NSSet *set = value;
  82 + for (id obj in [set sortedArrayUsingDescriptors:@[ sortDescriptor ]]) {
  83 + [mutableQueryStringComponents addObjectsFromArray:CNLiveQueryStringPairsFromKeyAndValue(key, obj)];
  84 + }
  85 + }else{ //其他类型
  86 + [mutableQueryStringComponents addObject:[[CNLiveReqSerialization alloc] initWithField:key value:value]];
  87 + }
  88 +
  89 + return mutableQueryStringComponents;
  90 +}
  91 +
  92 +static NSString * CNLivePercentEscapedStringFromString(NSString *string) {
  93 + static NSString * const kCNLiveCharactersGeneralDelimitersToEncode = @":#[]@"; // does not include "?" or "/" due to RFC 3986 - Section 3.4
  94 + static NSString * const kCNLiveCharactersSubDelimitersToEncode = @"!$&'()*+,;=";
  95 +
  96 + NSMutableCharacterSet * allowedCharacterSet = [[NSCharacterSet URLQueryAllowedCharacterSet] mutableCopy];
  97 + [allowedCharacterSet removeCharactersInString:[kCNLiveCharactersGeneralDelimitersToEncode stringByAppendingString:kCNLiveCharactersSubDelimitersToEncode]];
  98 +
  99 +
  100 + static NSUInteger const batchSize = 50;
  101 +
  102 + NSUInteger index = 0;
  103 + NSMutableString *escaped = @"".mutableCopy;
  104 +
  105 + while (index < string.length) {
  106 +#pragma GCC diagnostic push
  107 +#pragma GCC diagnostic ignored "-Wgnu"
  108 + NSUInteger length = MIN(string.length - index, batchSize);
  109 +#pragma GCC diagnostic pop
  110 + NSRange range = NSMakeRange(index, length);
  111 +
  112 + range = [string rangeOfComposedCharacterSequencesForRange:range];
  113 +
  114 + NSString *substring = [string substringWithRange:range];
  115 + NSString *encoded = [substring stringByAddingPercentEncodingWithAllowedCharacters:allowedCharacterSet];
  116 + [escaped appendString:encoded];
  117 +
  118 + index += range.length;
  119 + }
  120 +
  121 + return escaped;
  122 +}
  123 +
  124 +- (NSString *)URLEncodedStringValue {
  125 + if (!self.value || [self.value isEqual:[NSNull null]]) {
  126 + return CNLivePercentEscapedStringFromString([self.field description]);
  127 + } else {
  128 + return [NSString stringWithFormat:@"%@=%@", CNLivePercentEscapedStringFromString([self.field description]), CNLivePercentEscapedStringFromString([self.value description])];
  129 + }
  130 +}
  131 +@end
... ...
KS3SDKDemo/KS3SDKDemo/CNLiveUploadSDK.framework/CNLiveUploadSDK 0 → 100644
No preview for this file type
KS3SDKDemo/KS3SDKDemo/CNLiveUploadSDK.framework/Headers/CNLiveUpload.h 0 → 100644
  1 +//
  2 +// CNLiveUpload.h
  3 +// CNLiveUploadSDK
  4 +//
  5 +// Created by 张旭 on 2017/8/4.
  6 +// Copyright © 2017年 cnlive. All rights reserved.
  7 +//
  8 +
  9 +#import <Foundation/Foundation.h>
  10 +
  11 +@interface CNLiveUpload : NSObject
  12 +
  13 +/**
  14 + 初始化上传云SDK
  15 +
  16 + @param appId 在open.cnlive.com网站申请得到的appId
  17 + @param appKey 在open.cnlive.com网站申请得到的appKey
  18 + @param isTestEnvironment YES:测试环境 NO:正式环境
  19 + */
  20 ++ (void)setAppId:(NSString *)appId appKey:(NSString *)appKey isTestEnvironment:(BOOL)isTestEnvironment;
  21 +
  22 +/**
  23 + 获取鉴权字典
  24 +
  25 + @param md5 MD5加密数据
  26 + @param verb 请求方式GET/POST
  27 + @param type content-type
  28 + @param res 文件资源
  29 + @param headers 头文件信息
  30 + @param date 格林威治时间('D, d M Y H:i:s \G\M\T')
  31 +
  32 + */
  33 ++ (void)getAuthDicWithMd5:(NSString *)md5 verb:(NSString *)verb type:(NSString *)type res:(NSString *)res headers:(NSString *)headers date:(NSString *)date success:(void (^)(NSDictionary *dic))successBlock failure:(void (^)(NSDictionary *error))failureBlock;
  34 +@end
... ...
KS3SDKDemo/KS3SDKDemo/CNLiveUploadSDK.framework/Info.plist 0 → 100644
No preview for this file type
KS3SDKDemo/KS3SDKDemo/CreateBucketViewController.h 0 → 100755
  1 +//
  2 +// CreateBucketViewController.h
  3 +// KS3iOSSDKDemo
  4 +//
  5 +// Created by Blues on 12/16/14.
  6 +// Copyright (c) 2014 Blues. All rights reserved.
  7 +//
  8 +
  9 +#import <UIKit/UIKit.h>
  10 +
  11 +@interface CreateBucketViewController : UIViewController
  12 +
  13 +@end
... ...
KS3SDKDemo/KS3SDKDemo/CreateBucketViewController.m 0 → 100755
  1 +//
  2 +// CreateBucketViewController.m
  3 +// KS3iOSSDKDemo
  4 +//
  5 +// Created by Blues on 12/16/14.
  6 +// Copyright (c) 2014 Blues. All rights reserved.
  7 +//
  8 +
  9 +#import "CreateBucketViewController.h"
  10 +#import <KS3YunSDK.h>
  11 +
  12 +#import "KS3Util.h"
  13 +#import <CNLiveUploadSDK/CNLiveUpload.h>
  14 +@interface CreateBucketViewController ()
  15 +
  16 +@property (nonatomic, strong) IBOutlet UITextField *nameField;
  17 +
  18 +@end
  19 +
  20 +@implementation CreateBucketViewController
  21 +
  22 +- (void)viewDidLoad
  23 +{
  24 + [super viewDidLoad];
  25 + self.navigationItem.title = @"创建Bucket";
  26 +}
  27 +
  28 +- (IBAction)clickCreateBtn:(id)sender
  29 +{
  30 + NSString *strBucketName = _nameField.text;
  31 + KS3CreateBucketRequest *createBucketReq = [[KS3CreateBucketRequest alloc] initWithName:strBucketName];
  32 + [createBucketReq setCompleteRequest];
  33 +
  34 + NSArray *array = [createBucketReq.kSYHeader componentsSeparatedByString:@"\n"];
  35 + NSString *headers = [array firstObject];
  36 + [CNLiveUpload getAuthDicWithMd5:createBucketReq.contentMd5 verb:createBucketReq.httpMethod type:createBucketReq.contentType res:createBucketReq.kSYResource headers:headers date:createBucketReq.strDate success:^(NSDictionary *dic) {
  37 + //使用token签名时从Appserver获取token后设置token,使用Ak sk则忽略,不需要调用
  38 + [createBucketReq setStrKS3Token:dic[@"Authorization"]];
  39 + KS3CreateBucketResponse *response = [[KS3Client initialize] createBucket:createBucketReq];
  40 + if (response.httpStatusCode == 200) {
  41 + NSLog(@"Create bucket success!");
  42 + }
  43 + else {
  44 + NSLog(@"error: %@", response.error.localizedDescription);
  45 + }
  46 + } failure:^(NSDictionary *error) {
  47 + NSLog(@"error: %@", error);
  48 +
  49 + }];
  50 +
  51 +}
  52 +
  53 +
  54 +@end
... ...
KS3SDKDemo/KS3SDKDemo/GetAllObjectsViewController.h 0 → 100755
  1 +//
  2 +// GetBucketACLViewController.h
  3 +// KS3iOSSDKDemo
  4 +//
  5 +// Created by Blues on 12/16/14.
  6 +// Copyright (c) 2014 Blues. All rights reserved.
  7 +//
  8 +
  9 +#import <UIKit/UIKit.h>
  10 +
  11 +@interface GetAllObjectsViewController : UIViewController
  12 +
  13 +@end
... ...
KS3SDKDemo/KS3SDKDemo/GetAllObjectsViewController.m 0 → 100755
  1 +//
  2 +// GetBucketACLViewController.m
  3 +// KS3iOSSDKDemo
  4 +//
  5 +// Created by Blues on 12/16/14.
  6 +// Copyright (c) 2014 Blues. All rights reserved.
  7 +//
  8 +
  9 +#warning Please set correct bucket name
  10 +#define kBucketName @"acc"
  11 +//#define kBucketName @"alert1"
  12 +
  13 +#import "GetAllObjectsViewController.h"
  14 +#import <KS3YunSDK.h>
  15 +#import "KS3Util.h"
  16 +#import "AppDelegate.h"
  17 +#import <CNLiveUploadSDK/CNLiveUpload.h>
  18 +@interface GetAllObjectsViewController () <UIActionSheetDelegate>
  19 +
  20 +@property (nonatomic, strong) IBOutlet UITableView *objectTable;
  21 +@property (nonatomic, strong) NSArray *arrObjects;
  22 +@property (nonatomic, strong) NSIndexPath *selectIndexPath;
  23 +@property (nonatomic, strong) KS3ListObjectsResult *result;
  24 +
  25 +@end
  26 +
  27 +@implementation GetAllObjectsViewController
  28 +
  29 +- (void)viewDidLoad
  30 +{
  31 + [super viewDidLoad];
  32 + self.navigationItem.title = [NSString stringWithFormat:@"\"%@\"中所有的Objects", kBucketName];
  33 + UIBarButtonItem *rightBtn = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemAction target:self action:@selector(clickActionBtn:)];
  34 + self.navigationItem.rightBarButtonItem = rightBtn;
  35 +
  36 + [self listObjects];
  37 +}
  38 +
  39 +- (void)listObjects {
  40 + KS3ListObjectsRequest *listObjectRequest = [[KS3ListObjectsRequest alloc] initWithName:kBucketName];
  41 + [listObjectRequest setCompleteRequest];
  42 +
  43 + NSArray *array = [listObjectRequest.kSYHeader componentsSeparatedByString:@"\n"];
  44 + NSString *headers = [array firstObject];
  45 + [CNLiveUpload getAuthDicWithMd5:listObjectRequest.contentMd5 verb:listObjectRequest.httpMethod type:listObjectRequest.contentType res:listObjectRequest.kSYResource headers:headers date:listObjectRequest.strDate success:^(NSDictionary *dic) {
  46 + //使用token签名时从Appserver获取token后设置token,使用Ak sk则忽略,不需要调用
  47 + [listObjectRequest setStrKS3Token:dic[@"Authorization"]];
  48 +
  49 + KS3ListObjectsResponse *response = [[KS3Client initialize] listObjects:listObjectRequest];
  50 + _result = response.listBucketsResult;
  51 + _arrObjects = response.listBucketsResult.objectSummaries;
  52 + [_objectTable reloadData];
  53 +
  54 + for (KS3ObjectSummary *objectSummary in _arrObjects) {
  55 + NSLog(@"%@",objectSummary.Key);
  56 + NSLog(@"%@",objectSummary.owner.ID);
  57 + }
  58 + NSLog(@"%@",_result.bucketName);
  59 + NSLog(@"%ld",(long)_result.objectSummaries.count);
  60 + NSLog(@"%ld",(long)_result.commonPrefixes.count);
  61 +
  62 + NSLog(@"KSS3ListObjectsResponse %d",response.httpStatusCode);
  63 + }failure:^(NSDictionary *error) {
  64 + NSLog(@"error %@",error);
  65 + }];
  66 +}
  67 +
  68 +- (NSDictionary *)dicParamsWithReq:(KS3Request *)request {
  69 + NSDictionary *dicParams = [NSDictionary dictionaryWithObjectsAndKeys:
  70 + request.httpMethod, @"http_method",
  71 + request.contentMd5, @"content_md5",
  72 + request.contentType, @"content_type",
  73 + request.strDate, @"date",
  74 + request.kSYHeader, @"headers",
  75 + request.kSYResource, @"resource", nil];
  76 + return dicParams;
  77 +}
  78 +
  79 +#pragma mark - UITableView datasource
  80 +
  81 +- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
  82 +{
  83 + return _arrObjects.count;
  84 +}
  85 +
  86 +- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
  87 +{
  88 + NSString *strIdentifier = @"bucket identifier";
  89 + UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:strIdentifier];
  90 + if (nil == cell) {
  91 + cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:strIdentifier];
  92 + }
  93 + KS3ObjectSummary *object = _arrObjects[indexPath.row];
  94 + cell.textLabel.text = object.Key;
  95 + return cell;
  96 +}
  97 +
  98 +- (BOOL)tableView:(UITableView *)tableView canEditRowAtIndexPath:(NSIndexPath *)indexPath
  99 +{
  100 + return YES;
  101 +}
  102 +
  103 +- (void)tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath
  104 +{
  105 + _selectIndexPath = indexPath;
  106 + UIActionSheet *actionSheet = [[UIActionSheet alloc] initWithTitle:nil
  107 + delegate:self
  108 + cancelButtonTitle:@"Cancel"
  109 + destructiveButtonTitle:@"Delete"
  110 + otherButtonTitles:@"Edit Canned ACL", nil];
  111 + actionSheet.tag = 100;
  112 + [actionSheet showInView:self.view];
  113 +}
  114 +
  115 +- (NSString *)tableView:(NSString *)tableView titleForDeleteConfirmationButtonForRowAtIndexPath:(NSIndexPath *)indexPath
  116 +{
  117 + return @"More";
  118 +}
  119 +
  120 +#pragma mark - UIActionSheet delegate
  121 +
  122 +- (void)actionSheet:(UIActionSheet *)actionSheet clickedButtonAtIndex:(NSInteger)buttonIndex
  123 +{
  124 + KS3ObjectSummary *object = _arrObjects[_selectIndexPath.row];
  125 + if (actionSheet.tag == 100) {
  126 + switch (buttonIndex) {
  127 + case 0:
  128 + {
  129 + KS3DeleteObjectRequest *deleteObjRequest = [[KS3DeleteObjectRequest alloc] initWithName:kBucketName withKeyName:object.Key];
  130 +// deleteObjRequest.key = object.Key;
  131 +// NSDictionary *dicParams = [self dicParamsWithReq:deleteObjRequest];
  132 +//
  133 +// NSURL *tokenUrl = [NSURL URLWithString:@"http://0.0.0.0:11911"];
  134 +// NSMutableURLRequest *tokenRequest = [[NSMutableURLRequest alloc] initWithURL:tokenUrl
  135 +// cachePolicy:NSURLRequestReloadIgnoringLocalCacheData
  136 +// timeoutInterval:10];
  137 +// NSData *dataParams = [NSJSONSerialization dataWithJSONObject:dicParams options:NSJSONWritingPrettyPrinted error:nil];
  138 +// [tokenRequest setURL:tokenUrl];
  139 +// [tokenRequest setHTTPMethod:@"POST"];
  140 +// [tokenRequest setHTTPBody:dataParams];
  141 +// [NSURLConnection sendAsynchronousRequest:tokenRequest queue:[NSOperationQueue currentQueue] completionHandler:^(NSURLResponse *response, NSData *data, NSError *connectionError) {
  142 +// if (connectionError == nil) {
  143 +// NSString *strToken = [[NSString alloc] initWithData:data encoding:NSUTF8StringEncoding];
  144 +// NSLog(@"#### 获取token成功! #### token: %@", strToken);
  145 +// deleteObjRequest.strKS3Token = strToken;
  146 +// KS3DeleteObjectResponse *response = [[KS3Client initialize] deleteObject:deleteObjRequest];
  147 +// if (response.httpStatusCode == 204) {
  148 +// NSLog(@"Delete object success!");
  149 +// [self listObjects];
  150 +// }
  151 +// else {
  152 +// NSLog(@"Delete object error: %@", response.error.description);
  153 +// }
  154 +// }
  155 +// else {
  156 +// NSLog(@"#### 获取token失败,error: %@", connectionError);
  157 +// }
  158 +// }];
  159 + KS3DeleteObjectResponse *response = [[KS3Client initialize] deleteObject:deleteObjRequest];
  160 + if (response.httpStatusCode == 204) {
  161 + NSLog(@"Delete object success!");
  162 + [self listObjects];
  163 + }
  164 + else {
  165 + NSLog(@"Delete object error: %@", response.error.description);
  166 + }
  167 + }
  168 + break;
  169 + case 1:
  170 + {
  171 + UIActionSheet *aclActionSheet = [[UIActionSheet alloc] initWithTitle:nil
  172 + delegate:self
  173 + cancelButtonTitle:@"Cancel"
  174 + destructiveButtonTitle:nil
  175 + otherButtonTitles:@"Private", @"Public-Read", @"Public-Read-Write", @"Authenticated-Read", nil];
  176 + aclActionSheet.tag = 101;
  177 + [aclActionSheet showInView:self.view];
  178 + }
  179 + break;
  180 + case 2:
  181 + NSLog(@"Cancel object");
  182 + break;
  183 + default:
  184 + break;
  185 + }
  186 + }
  187 + else if (actionSheet.tag == 101) {
  188 + KingSoftYun_PermissionACLType cannedACLType = KingSoftYun_Permission_Private;
  189 + switch (buttonIndex) {
  190 + case 0:
  191 + cannedACLType = KingSoftYun_Permission_Private;
  192 + break;
  193 + case 1:
  194 + cannedACLType = KingSoftYun_Permission_Public_Read;
  195 + break;
  196 + case 2:
  197 + cannedACLType = KingSoftYun_Permission_Public_Read_Write;
  198 + break;
  199 + case 3:
  200 + cannedACLType = KingSoftYun_Permission_Authenticated_Read;
  201 + break;
  202 + case 4:
  203 + NSLog(@"Cancel ACL Setting");
  204 + break;
  205 + default:
  206 + break;
  207 + }
  208 + KS3AccessControlList *acl = [[KS3AccessControlList alloc] init];
  209 + [acl setContronAccess:cannedACLType];
  210 + KS3SetObjectACLRequest *setObjectACLRequest = [[KS3SetObjectACLRequest alloc] initWithName:kBucketName withKeyName:object.Key acl:acl];
  211 +// setObjectACLRequest.key = object.Key;
  212 +// setObjectACLRequest.acl = acl;
  213 +// NSDictionary *dicParams = [self dicParamsWithReq:setObjectACLRequest];
  214 +//
  215 +// NSURL *tokenUrl = [NSURL URLWithString:@"http://0.0.0.0:11911"];
  216 +// NSMutableURLRequest *tokenRequest = [[NSMutableURLRequest alloc] initWithURL:tokenUrl
  217 +// cachePolicy:NSURLRequestReloadIgnoringLocalCacheData
  218 +// timeoutInterval:10];
  219 +// NSData *dataParams = [NSJSONSerialization dataWithJSONObject:dicParams options:NSJSONWritingPrettyPrinted error:nil];
  220 +// [tokenRequest setURL:tokenUrl];
  221 +// [tokenRequest setHTTPMethod:@"POST"];
  222 +// [tokenRequest setHTTPBody:dataParams];
  223 +// [NSURLConnection sendAsynchronousRequest:tokenRequest queue:[NSOperationQueue currentQueue] completionHandler:^(NSURLResponse *response, NSData *data, NSError *connectionError) {
  224 +// if (connectionError == nil) {
  225 +// NSString *strToken = [[NSString alloc] initWithData:data encoding:NSUTF8StringEncoding];
  226 +// NSLog(@"#### 获取token成功! #### token: %@", strToken);
  227 +// setObjectACLRequest.strKS3Token = strToken;
  228 +// KS3SetObjectACLResponse *response = [[KS3Client initialize] setObjectACL:setObjectACLRequest];
  229 +// if (response.httpStatusCode == 200) {
  230 +// NSLog(@"Set object acl success!");
  231 +// UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:nil
  232 +// message:@"Set object acl success!"
  233 +// delegate:nil
  234 +// cancelButtonTitle:@"OK"
  235 +// otherButtonTitles:nil];
  236 +// [alertView show];
  237 +// }
  238 +// else {
  239 +// NSLog(@"Set object acl error: %@", response.error.description);
  240 +// }
  241 +// }
  242 +// else {
  243 +// NSLog(@"#### 获取token失败,error: %@", connectionError);
  244 +// }
  245 +// }];
  246 + KS3SetObjectACLResponse *response = [[KS3Client initialize] setObjectACL:setObjectACLRequest];
  247 + if (response.httpStatusCode == 200) {
  248 + NSLog(@"Set object acl success!");
  249 + UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:nil
  250 + message:@"Set object acl success!"
  251 + delegate:nil
  252 + cancelButtonTitle:@"OK"
  253 + otherButtonTitles:nil];
  254 + [alertView show];
  255 + }
  256 + else {
  257 + NSLog(@"Set object acl error: %@", response.error.description);
  258 + }
  259 + }
  260 + else if (actionSheet.tag == 102) {
  261 + switch (buttonIndex) {
  262 + case 0:
  263 + NSLog(@"Upload");
  264 + break;
  265 + case 1:
  266 + NSLog(@"Download");
  267 + break;
  268 + case 2:
  269 + NSLog(@"Cancel object action");
  270 + break;
  271 + default:
  272 + break;
  273 + }
  274 + }
  275 +}
  276 +
  277 +#pragma mark - Actions
  278 +
  279 +- (void)clickActionBtn:(id)sender
  280 +{
  281 + UIActionSheet *actionSheet = [[UIActionSheet alloc] initWithTitle:nil
  282 + delegate:self
  283 + cancelButtonTitle:@"Cancel"
  284 + destructiveButtonTitle:nil
  285 + otherButtonTitles:@"Upload", @"Download", nil];
  286 + actionSheet.tag = 102;
  287 + [actionSheet showInView:self.view];
  288 +}
  289 +
  290 +@end
... ...
KS3SDKDemo/KS3SDKDemo/Info.plist 0 → 100755
  1 +<?xml version="1.0" encoding="UTF-8"?>
  2 +<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
  3 +<plist version="1.0">
  4 +<dict>
  5 + <key>CFBundleDevelopmentRegion</key>
  6 + <string>en</string>
  7 + <key>CFBundleExecutable</key>
  8 + <string>$(EXECUTABLE_NAME)</string>
  9 + <key>CFBundleIdentifier</key>
  10 + <string>$(PRODUCT_BUNDLE_IDENTIFIER)</string>
  11 + <key>CFBundleInfoDictionaryVersion</key>
  12 + <string>6.0</string>
  13 + <key>CFBundleName</key>
  14 + <string>$(PRODUCT_NAME)</string>
  15 + <key>CFBundlePackageType</key>
  16 + <string>APPL</string>
  17 + <key>CFBundleShortVersionString</key>
  18 + <string>1.0</string>
  19 + <key>CFBundleVersion</key>
  20 + <string>1</string>
  21 + <key>LSRequiresIPhoneOS</key>
  22 + <true/>
  23 + <key>NSAppTransportSecurity</key>
  24 + <dict>
  25 + <key>NSAllowsArbitraryLoads</key>
  26 + <true/>
  27 + </dict>
  28 + <key>NSPhotoLibraryAddUsageDescription</key>
  29 + <string></string>
  30 + <key>NSPhotoLibraryUsageDescription</key>
  31 + <string>Use photo to test upload</string>
  32 + <key>UILaunchStoryboardName</key>
  33 + <string>LaunchScreen</string>
  34 + <key>UIMainStoryboardFile</key>
  35 + <string>Main</string>
  36 + <key>UIRequiredDeviceCapabilities</key>
  37 + <array>
  38 + <string>armv7</string>
  39 + </array>
  40 + <key>UISupportedInterfaceOrientations</key>
  41 + <array>
  42 + <string>UIInterfaceOrientationPortrait</string>
  43 + <string>UIInterfaceOrientationLandscapeLeft</string>
  44 + <string>UIInterfaceOrientationLandscapeRight</string>
  45 + </array>
  46 + <key>UISupportedInterfaceOrientations~ipad</key>
  47 + <array>
  48 + <string>UIInterfaceOrientationPortrait</string>
  49 + <string>UIInterfaceOrientationPortraitUpsideDown</string>
  50 + <string>UIInterfaceOrientationLandscapeLeft</string>
  51 + <string>UIInterfaceOrientationLandscapeRight</string>
  52 + </array>
  53 +</dict>
  54 +</plist>
... ...
KS3SDKDemo/KS3SDKDemo/KS3Util.h 0 → 100755
  1 +//
  2 +// KS3Util.h
  3 +// KS3iOSSDKDemo
  4 +//
  5 +// Created by JackWong on 15/4/24.
  6 +// Copyright (c) 2015年 Blues. All rights reserved.
  7 +//
  8 +
  9 +#import <Foundation/Foundation.h>
  10 +@class KS3Request;
  11 +@interface KS3Util : NSObject
  12 +/*
  13 + 此类是客户端用aksk计算签名。
  14 + 1.若使用token方式,不建议客户端去计算,不安全,应由客户端请求服务端去根据aksk计算签名返回。
  15 + 2.若使用aksk方式,可计算签名
  16 +
  17 + */
  18 +
  19 +//+ (NSString *)getAuthorization:(KS3Request *)request;
  20 ++ (NSData *)dataWithSize:(NSUInteger)size;
  21 +
  22 +@end
... ...
KS3SDKDemo/KS3SDKDemo/KS3Util.m 0 → 100755
  1 +//
  2 +// KS3Util.m
  3 +// KS3iOSSDKDemo
  4 +//
  5 +// Created by JackWong on 15/4/24.
  6 +// Copyright (c) 2015年 Blues. All rights reserved.
  7 +//
  8 +
  9 +#import "KS3Util.h"
  10 +#import <CommonCrypto/CommonHMAC.h>
  11 +#import <CommonCrypto/CommonDigest.h>
  12 +#import <KS3Request.h>
  13 +#import <KS3AuthUtils.h>
  14 +#import "AppDelegate.h"
  15 +
  16 +@implementation KS3Util
  17 +//+ (NSString *)getAuthorization:(KS3Request *)request
  18 +//{
  19 +// return [KS3AuthUtils KSYAuthorizationWithAccessKey:strAccessKey
  20 +// secretKey:strSecretKey
  21 +// httpVerb:request.httpMethod
  22 +// contentMd5:request.contentMd5
  23 +// contentType:request.contentType
  24 +// strDate:request.strDate
  25 +// canonicalizedKssHeader:request.kSYHeader
  26 +// canonicalizedResource:request.kSYResource];
  27 +//}
  28 +
  29 ++ (NSData *)dataWithSize:(NSUInteger)size {
  30 + return [[NSMutableData dataWithLength:size] copy];
  31 +}
  32 +
  33 +@end
... ...
KS3SDKDemo/KS3SDKDemo/ListBucketViewController.h 0 → 100755
  1 +//
  2 +// ListBucketViewController.h
  3 +// KS3iOSSDKDemo
  4 +//
  5 +// Created by Blues on 12/16/14.
  6 +// Copyright (c) 2014 Blues. All rights reserved.
  7 +//
  8 +
  9 +#import <UIKit/UIKit.h>
  10 +
  11 +@interface ListBucketViewController : UIViewController
  12 +
  13 +@end
... ...
KS3SDKDemo/KS3SDKDemo/ListBucketViewController.m 0 → 100755
  1 +//
  2 +// ListBucketViewController.m
  3 +// KS3iOSSDKDemo
  4 +//
  5 +// Created by Blues on 12/16/14.
  6 +// Copyright (c) 2014 Blues. All rights reserved.
  7 +//
  8 +
  9 +#import "ListBucketViewController.h"
  10 +#import <KS3YunSDK.h>
  11 +#import "KS3Util.h"
  12 +#import "AppDelegate.h"
  13 +#import <CNLiveUploadSDK/CNLiveUpload.h>
  14 +@interface ListBucketViewController () <UIActionSheetDelegate>
  15 +
  16 +@property (nonatomic, strong) IBOutlet UITableView *bucketListTable;
  17 +@property (nonatomic, strong) NSIndexPath *selectIndexPath;
  18 +@property (nonatomic, strong) NSArray *arrBuckets;
  19 +
  20 +@end
  21 +
  22 +@implementation ListBucketViewController
  23 +
  24 +- (void)viewDidLoad
  25 +{
  26 + [super viewDidLoad];
  27 + self.navigationItem.title = @"Bucket列表";
  28 + UIBarButtonItem *addBtnItem = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemAdd
  29 + target:self
  30 + action:@selector(clickAddBucketBtn:)];
  31 + self.navigationItem.rightBarButtonItem = addBtnItem;
  32 +
  33 + // **** token 方式
  34 + [self listBuckets];
  35 +}
  36 +
  37 +- (void)listBuckets {
  38 + KS3ListBucketsRequest *listBucketRequest = [[KS3ListBucketsRequest alloc] init];
  39 + [listBucketRequest setCompleteRequest];
  40 +
  41 + NSArray *array = [listBucketRequest.kSYHeader componentsSeparatedByString:@"\n"];
  42 + NSString *headers = [array firstObject];
  43 + [CNLiveUpload getAuthDicWithMd5:listBucketRequest.contentMd5 verb:listBucketRequest.httpMethod type:listBucketRequest.contentType res:listBucketRequest.kSYResource headers:headers date:listBucketRequest.strDate success:^(NSDictionary *dic) {
  44 + //使用token签名时从Appserver获取token后设置token,使用Ak sk则忽略,不需要调用
  45 + [listBucketRequest setStrKS3Token:dic[@"Authorization"]];
  46 +
  47 + // **** use ak/sk
  48 + _arrBuckets = [[KS3Client initialize] listBuckets:(KS3ListBucketsRequest *)listBucketRequest];
  49 + [_bucketListTable reloadData];
  50 + }failure:^(NSDictionary *error) {
  51 + NSLog(@"error %@",error);
  52 + }];
  53 +}
  54 +
  55 +#pragma mark - UITableView datasource
  56 +
  57 +- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
  58 +{
  59 + return _arrBuckets.count;
  60 +}
  61 +
  62 +- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
  63 +{
  64 + NSString *strIdentifier = @"list bucket identifier";
  65 + UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:strIdentifier];
  66 + if (nil == cell) {
  67 + cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:strIdentifier];
  68 + }
  69 + KS3Bucket *bucketObj = _arrBuckets[indexPath.row];
  70 + cell.textLabel.text = bucketObj.name;
  71 + return cell;
  72 +}
  73 +
  74 +//- (BOOL)tableView:(UITableView *)tableView canEditRowAtIndexPath:(NSIndexPath *)indexPath
  75 +//{
  76 +// return YES;
  77 +//}
  78 +//
  79 +//- (void)tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath
  80 +//{
  81 +// _selectIndexPath = indexPath;
  82 +// UIActionSheet *actionSheet = [[UIActionSheet alloc] initWithTitle:nil
  83 +// delegate:self
  84 +// cancelButtonTitle:@"Cancel"
  85 +// destructiveButtonTitle:@"Delete"
  86 +// otherButtonTitles:@"Edit Canned ACL", nil];
  87 +// actionSheet.tag = 100;
  88 +// [actionSheet showInView:self.view];
  89 +//}
  90 +//
  91 +//- (NSString *)tableView:(NSString *)tableView titleForDeleteConfirmationButtonForRowAtIndexPath:(NSIndexPath *)indexPath
  92 +//{
  93 +// return @"More";
  94 +//}
  95 +
  96 +#pragma mark - UIActionSheet delegate
  97 +
  98 +- (void)actionSheet:(UIActionSheet *)actionSheet clickedButtonAtIndex:(NSInteger)buttonIndex
  99 +{
  100 + KS3Bucket *bucketObj = _arrBuckets[_selectIndexPath.row];
  101 + if (actionSheet.tag == 100) {
  102 + switch (buttonIndex) {
  103 + case 0:
  104 + {
  105 + KS3DeleteBucketRequest *deleteBucketReq = [[KS3DeleteBucketRequest alloc] initWithName:bucketObj.name];
  106 + NSDictionary *dicParams = [self dicParamsWithReq:deleteBucketReq];
  107 + NSURL *tokenUrl = [NSURL URLWithString:@"http://0.0.0.0:11911"];
  108 + NSMutableURLRequest *tokenRequest = [[NSMutableURLRequest alloc] initWithURL:tokenUrl
  109 + cachePolicy:NSURLRequestReloadIgnoringLocalCacheData
  110 + timeoutInterval:10];
  111 + NSData *dataParams = [NSJSONSerialization dataWithJSONObject:dicParams options:NSJSONWritingPrettyPrinted error:nil];
  112 + [tokenRequest setURL:tokenUrl];
  113 + [tokenRequest setHTTPMethod:@"POST"];
  114 + [tokenRequest setHTTPBody:dataParams];
  115 + [NSURLConnection sendAsynchronousRequest:tokenRequest queue:[NSOperationQueue currentQueue] completionHandler:^(NSURLResponse *response, NSData *data, NSError *connectionError) {
  116 + if (connectionError == nil) {
  117 + NSString *strToken = [[NSString alloc] initWithData:data encoding:NSUTF8StringEncoding];
  118 + NSLog(@"#### 获取token成功! #### token: %@", strToken);
  119 + deleteBucketReq.strKS3Token = strToken;
  120 + KS3DeleteBucketResponse *response = [[KS3Client initialize] deleteBucket:deleteBucketReq];
  121 + if (response.httpStatusCode == 204) { // **** 没有返回任何内容
  122 + NSLog(@"Delete bucket success!");
  123 + [self listBuckets];
  124 + }
  125 + else {
  126 + NSLog(@"Delete bucket error: %@", response.error.description);
  127 + }
  128 + }
  129 + else {
  130 + NSLog(@"#### 获取token失败,error: %@", connectionError);
  131 + }
  132 + }];
  133 + }
  134 + break;
  135 + case 1:
  136 + {
  137 + UIActionSheet *aclActionSheet = [[UIActionSheet alloc] initWithTitle:nil
  138 + delegate:self
  139 + cancelButtonTitle:@"Cancel"
  140 + destructiveButtonTitle:nil
  141 + otherButtonTitles:@"Private", @"Public-Read", @"Public-Read-Write", @"Authenticated-Read", nil];
  142 + aclActionSheet.tag = 101;
  143 + [aclActionSheet showInView:self.view];
  144 + }
  145 + break;
  146 + case 2:
  147 + NSLog(@"Cancel More");
  148 + break;
  149 + default:
  150 + break;
  151 + }
  152 + }
  153 + else if (actionSheet.tag == 101) {
  154 + KingSoftYun_PermissionACLType cannedACLType = KingSoftYun_Permission_Private;
  155 + switch (buttonIndex) {
  156 + case 0:
  157 + cannedACLType = KingSoftYun_Permission_Private;
  158 + break;
  159 + case 1:
  160 + cannedACLType = KingSoftYun_Permission_Public_Read;
  161 + break;
  162 + case 2:
  163 + cannedACLType = KingSoftYun_Permission_Public_Read_Write;
  164 + break;
  165 + case 3:
  166 + cannedACLType = KingSoftYun_Permission_Authenticated_Read;
  167 + break;
  168 + case 4:
  169 + NSLog(@"Cancel ACL Setting");
  170 + break;
  171 + default:
  172 + break;
  173 + }
  174 + KS3AccessControlList *acl = [[KS3AccessControlList alloc] init];
  175 + [acl setContronAccess:cannedACLType];
  176 + KS3SetACLRequest *setACLRequest = [[KS3SetACLRequest alloc] initWithName:bucketObj.name accessACL:acl] ;
  177 +
  178 +// setACLRequest.acl = acl;
  179 + NSDictionary *dicParams = [self dicParamsWithReq:setACLRequest];
  180 + NSURL *tokenUrl = [NSURL URLWithString:@"http://0.0.0.0:11911"];
  181 + NSMutableURLRequest *tokenRequest = [[NSMutableURLRequest alloc] initWithURL:tokenUrl
  182 + cachePolicy:NSURLRequestReloadIgnoringLocalCacheData
  183 + timeoutInterval:10];
  184 + NSData *dataParams = [NSJSONSerialization dataWithJSONObject:dicParams options:NSJSONWritingPrettyPrinted error:nil];
  185 + [tokenRequest setURL:tokenUrl];
  186 + [tokenRequest setHTTPMethod:@"POST"];
  187 + [tokenRequest setHTTPBody:dataParams];
  188 + [NSURLConnection sendAsynchronousRequest:tokenRequest queue:[NSOperationQueue currentQueue] completionHandler:^(NSURLResponse *response, NSData *data, NSError *connectionError) {
  189 + if (connectionError == nil) {
  190 + NSString *strToken = [[NSString alloc] initWithData:data encoding:NSUTF8StringEncoding];
  191 + NSLog(@"#### 获取token成功! #### token: %@", strToken);
  192 + setACLRequest.strKS3Token = strToken;
  193 + KS3SetACLResponse *response = [[KS3Client initialize] setBucketACL:setACLRequest];
  194 + if (response.httpStatusCode == 200) {
  195 + NSLog(@"Set bucket acl success!");
  196 + UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:nil
  197 + message:@"Set bucket acl success!"
  198 + delegate:nil
  199 + cancelButtonTitle:@"OK"
  200 + otherButtonTitles:nil];
  201 + [alertView show];
  202 + }
  203 + else {
  204 + NSLog(@"Set bucket acl error: %@", response.error.description);
  205 + }
  206 + }
  207 + else {
  208 + NSLog(@"#### 获取token失败,error: %@", connectionError);
  209 + }
  210 + }];
  211 + }
  212 +}
  213 +
  214 +#pragma mark - Actions
  215 +
  216 +- (void)clickAddBucketBtn:(id)sender
  217 +{
  218 + UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:@"Create Bucket"
  219 + message:nil
  220 + delegate:self
  221 + cancelButtonTitle:@"Cancel"
  222 + otherButtonTitles:@"Create", nil];
  223 + alertView.alertViewStyle = UIAlertViewStylePlainTextInput;
  224 + UITextField *nameField = [alertView textFieldAtIndex:0];
  225 + nameField.placeholder = @"Bucket Name";
  226 + [alertView show];
  227 +}
  228 +
  229 +#pragma mark - UIAlertView delegate
  230 +
  231 +- (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex
  232 +{
  233 + if (buttonIndex == 1) {
  234 + UITextField *nameField = [alertView textFieldAtIndex:0];
  235 + KS3CreateBucketRequest *createBucketReq = [[KS3CreateBucketRequest alloc] initWithName:nameField.text];
  236 + NSDictionary *dicParams = [self dicParamsWithReq:createBucketReq];
  237 + NSURL *tokenUrl = [NSURL URLWithString:@"http://0.0.0.0:11911"];
  238 + NSMutableURLRequest *tokenRequest = [[NSMutableURLRequest alloc] initWithURL:tokenUrl
  239 + cachePolicy:NSURLRequestReloadIgnoringLocalCacheData
  240 + timeoutInterval:10];
  241 + NSData *dataParams = [NSJSONSerialization dataWithJSONObject:dicParams options:NSJSONWritingPrettyPrinted error:nil];
  242 + [tokenRequest setURL:tokenUrl];
  243 + [tokenRequest setHTTPMethod:@"POST"];
  244 + [tokenRequest setHTTPBody:dataParams];
  245 + [NSURLConnection sendAsynchronousRequest:tokenRequest queue:[NSOperationQueue currentQueue] completionHandler:^(NSURLResponse *response, NSData *data, NSError *connectionError) {
  246 + if (connectionError == nil) {
  247 + NSString *strToken = [[NSString alloc] initWithData:data encoding:NSUTF8StringEncoding];
  248 + NSLog(@"#### 获取token成功! #### token: %@", strToken);
  249 + createBucketReq.strKS3Token = strToken;
  250 + KS3CreateBucketResponse *response = [[KS3Client initialize] createBucket:createBucketReq];
  251 + if (response.httpStatusCode == 200) {
  252 + NSLog(@"Create bucket success!");
  253 + [self listBuckets];
  254 + }
  255 + else {
  256 + NSLog(@"error: %@", response.error.localizedDescription);
  257 + }
  258 + }
  259 + else {
  260 + NSLog(@"#### 获取token失败,error: %@", connectionError);
  261 + }
  262 + }];
  263 + }
  264 +}
  265 +
  266 +- (BOOL)alertViewShouldEnableFirstOtherButton:(UIAlertView *)alertView
  267 +{
  268 + UITextField *nameField = [alertView textFieldAtIndex:0];
  269 + if ([nameField.text isEqualToString:@""] == YES) {
  270 + return NO;
  271 + }
  272 + return YES;
  273 +}
  274 +
  275 +- (NSDictionary *)dicParamsWithReq:(KS3Request *)request {
  276 + NSDictionary *dicParams = [NSDictionary dictionaryWithObjectsAndKeys:
  277 + request.httpMethod, @"http_method",
  278 + request.contentMd5, @"content_md5",
  279 + request.contentType, @"content_type",
  280 + request.strDate, @"date",
  281 + request.kSYHeader, @"headers",
  282 + request.kSYResource, @"resource", nil];
  283 + return dicParams;
  284 +}
  285 +
  286 +@end
... ...
KS3SDKDemo/KS3SDKDemo/ObjectViewController.h 0 → 100755
  1 +//
  2 +// ObjectViewController.h
  3 +// KS3iOSSDKDemo
  4 +//
  5 +// Created by Blues on 12/17/14.
  6 +// Copyright (c) 2014 Blues. All rights reserved.
  7 +//
  8 +
  9 +#import <UIKit/UIKit.h>
  10 +
  11 +
  12 +@interface ObjectViewController : UIViewController
  13 +
  14 +@end
... ...
KS3SDKDemo/KS3SDKDemo/ObjectViewController.m 0 → 100755
  1 +//
  2 +// ObjectViewController.m
  3 +// KS3iOSSDKDemo
  4 +//
  5 +// Created by Blues on 12/17/14.
  6 +// Copyright (c) 2014 Blues. All rights reserved.
  7 +//
  8 +
  9 +
  10 +
  11 +/*
  12 + KS3 API文档:http://ks3.ksyun.com/doc/index.html
  13 + 开发前请阅读: KS3 - iOS -SDK 文档地址 https://github.com/ks3sdk/ks3-ios-sdk
  14 + KS3 存储控制台地址 http://www.ksyun.com/user/login?
  15 +
  16 + 上传下载几点概念术语必读:
  17 +
  18 + AccessKey(访问秘钥)、SecretKey
  19 + 使用KS3,您需要KS3颁发给您的AccessKey(长度为20个字符的ASCII字符串)和SecretKey(长度为40个字符的ASCII字符串)。AccessKey用于标识客户的身份,SecretKey作为私钥形式存放于客户服务器不在网络中传递。SecretKey通常用作计算请求签名的密钥,用以保证该请求是来自指定的客户。使用AccessKey进行身份识别,加上SecretKey进行数字签名,即可完成应用接入与认证授权。AK/SK在AppDelegate.m 里配置,模拟app服务器返回token
  20 +
  21 + Bucket(存储空间)
  22 + Bucket是存放Object的容器,所有的Object都必须存放在特定的Bucket中。每个用户最多可以创建20个Bucket,每个Bucket中可以存放无限多个Object。Bucket不能嵌套,每个Bucket中只能存放Object,不能再存放Bucket,Bucket下的Object是一个平级的结构。Bucket的名称全局唯一且命名规则与DNS命名规则相同:
  23 + 仅包含小写英文字母(a-z),数字,点(.),中线,即: abcdefghijklmnopqrstuvwxyz0123456789.-
  24 + 必须由字母或数字开头
  25 + 长度在3和255个字符之间
  26 + 不能是IP的形式,类似192.168.0.1
  27 + 不能以kss开头
  28 +
  29 + Object(对象,文件)
  30 + 在KS3中,用户操作的基本数据单元是Object。单个Object允许存储0~5TB的数据。 Object 包含key和data。其中,key是Object的名字;data是Object 的数据。key为UTF-8编码,且编码后的长度不得超过1024个字节。
  31 +
  32 + Key(文件名)
  33 + 即Object的名字,key为UTF-8编码,且编码后的长度不得超过1024个字节。Key中可以带有斜杠,当Key中带有斜杠的时候,将会自动在控制台里组织成目录结构。
  34 +
  35 + ACL(访问控制权限)
  36 + 对Bucket和Object相关访问的控制策略,例如允许匿名用户公开访问等。
  37 + 目前ACL支持READ, WRITE, FULL_CONTROL三种权限。对于bucket的拥有者,总是FULL_CONTROL。可以授予所有用户(包括匿名用户)或指定用户READ, WRITE, 或者FULL_CONTROL权限。
  38 + 目前提供了三种预设的ACL.分别是private、public-read和public-read-write。public-read表示为所有用户授予READ权限,public-read-write表示为所有用户授予WRITE权限.使用的时候通过在header中添加x-kss-acl实现。
  39 + 对于BUCKET来说,READ是指罗列Bucket中的文件、罗列Bucket中正在进行的分块上传、罗列某个分块上传已经上传的块。WRITE是指可以上传,删除BUCKET中文件的功能。FULL_CONTROL则包含所有操作。可以通过PUT Bucket acl接口设置。
  40 + 对于Object来说,READ是指查看或者下载文件的功能。WRITE无意义。FULL_CONTROL则包含所有操作。可以通过PUT Object acl设置。
  41 +
  42 + * 创建bucket时需要选择Region,如遇到上传卡住或超时,请确认工程中对应的外网域名,SDK默认北京,设置
  43 + - (void)setBucketDomainWithRegion:(KS3BucketDomainRegion)domainRegion;
  44 + Region中文名称 外网域名 内网域名
  45 + 中国(北京) ks3-cn-beijing.ksyun.com ks3-cn-beijing-internal.ksyun.com
  46 + 美国(圣克拉拉) ks3-us-west-1.ksyun.com ks3-us-west-1-internal.ksyun.com
  47 + 中国(香港) ks3-cn-hk-1.ksyun.com ks3-cn-hk-1-internal.ksyun.com
  48 +
  49 +
  50 + */
  51 +
  52 +#warning Please set correct bucket and object name
  53 +
  54 +//Demo下载文件的地址:http://ecloud.kssws.ks-cdn.com/test2/Test.pdf
  55 +
  56 +//上传
  57 +#define kUploadBucketName @"compose" //上传所用的bucketName
  58 +#define kUploadBucketKey @"7.6M.mov" //上传时用到的bucket里文件的路径,此为在wz目录下7.6M.mov
  59 +#define keyUploadPartNum @"partNum" //需要app本地存储已经传成功的块号,demo为了演示,用NSUserDefaults存储,app可用数据库等
  60 +#define keyUploadId @"uploadId" //需要app本地存储已经初始化成功的uploadId,用于断点续传,demo为了演示,用NSUserDefaults存储,app可用数据库等
  61 +
  62 +//下载
  63 +#define kDownloadBucketName @"test-voidmain-hz-2"//下载所用的bucketName
  64 +#define kDownloadBucketKey @"wz/7.6M.mov" //下载的文件所在bucket的路径
  65 +#define kDownloadSize 21131496 //Demo下载文件的大小,根据业务需求,显示进度条时用到,需要记录,app可用数据库等
  66 +
  67 +#define kBucketName @"acc"//@"alert1"//@"bucketcors"//@"alert1"
  68 +#define kObjectName @"Count_1.txt"//@"test_download.txt"//@"bug.txt"
  69 +#define kDesBucketName @"blues11"//@"ggg"//
  70 +#define kDesObjectName @"bug_copy.txt"
  71 +#define kObjectSpecial1 @"+-.jpg"
  72 +#define kObjectSpecial2 @"+-.txt"
  73 +
  74 +#define mScreenWidth ([UIScreen mainScreen].bounds.size.width)
  75 +#define mScreenHeight ([UIScreen mainScreen].bounds.size.height)
  76 +#define mUserDefaults [NSUserDefaults standardUserDefaults]
  77 +#define FileBlockSize 5*1024*1024 //一块大小,分块最小5M
  78 +#import "ObjectViewController.h"
  79 +#import <KS3YunSDK.h>
  80 +#import "KS3Util.h"
  81 +#import "AppDelegate.h"
  82 +#import <AssetsLibrary/AssetsLibrary.h>
  83 +
  84 +#import "CNLiveCommonTools.h"
  85 +#import "CNLiveNetManager.h"
  86 +#import <CNLiveUploadSDK/CNLiveUpload.h>
  87 +
  88 +@interface ObjectViewController () <KingSoftServiceRequestDelegate>
  89 +@property (nonatomic, strong) NSArray *arrItems;
  90 +@property (nonatomic, strong) KS3DownLoad *downloader;
  91 +
  92 +@property (strong, nonatomic) NSFileHandle *fileHandle;
  93 +@property (assign, nonatomic) NSInteger partSize;
  94 +@property (assign, nonatomic) long long fileSize;
  95 +@property (assign, nonatomic) long long partLength;
  96 +@property (nonatomic) NSInteger totalNum;
  97 +@property (nonatomic) NSInteger uploadNum;
  98 +@property (nonatomic, strong) NSString *bucketName;
  99 +@property (strong, nonatomic) KS3MultipartUpload *muilt;
  100 +
  101 +@property (nonatomic, strong) KS3UploadManager *uploadManager;
  102 +
  103 +@end
  104 +
  105 +@implementation ObjectViewController
  106 +
  107 +- (void)viewDidLoad
  108 +{
  109 + [super viewDidLoad];
  110 +
  111 +// [[KS3Client initialize] setCredentials:[[KS3Credentials alloc] initWithAccessKey:strAccessKey withSecretKey:strSecretKey]];
  112 +
  113 + self.navigationItem.title = @"Object";
  114 + _arrItems = [NSArray arrayWithObjects:
  115 + @"Get Object", @"Delete Object", @"Head Object", @"Put Object", @"Put Object Copy", @"Post Object",
  116 + @"Get Object ACL", @"Set Object ACL", @"Set Object Grant ACL",
  117 + @"Multipart Upload", @"Pause Download", @"Abort Upload", @"Upload Manager", @"Put Object 1M", @"Put Object 5M", @"Put Object 10M", @"Put Object 50M", nil];
  118 + UIButton *rightBtn = [[UIButton alloc]initWithFrame:CGRectMake(0, 0, 100, 44)];
  119 + [rightBtn setTitleColor:[UIColor blueColor] forState:UIControlStateNormal];
  120 + rightBtn.titleLabel.font = [UIFont systemFontOfSize:14];
  121 + [rightBtn setTitle:@"删除已下载" forState:UIControlStateNormal];
  122 + [rightBtn addTarget:self action:@selector(deleteFinishedFile) forControlEvents:UIControlEventTouchUpInside];
  123 + self.navigationItem.rightBarButtonItem = [[UIBarButtonItem alloc]initWithCustomView:rightBtn] ;
  124 +
  125 +
  126 + //[mUserDefaults setBool:NO forKey:@"SavedVideo"];
  127 +
  128 + //向模拟器相册,存储一段测试视频,用于模拟相册分块上传
  129 + if ( [mUserDefaults boolForKey:@"SavedVideo"] == NO) {
  130 + [mUserDefaults setBool:YES forKey:@"SavedVideo"];
  131 + NSString *path = [[NSBundle mainBundle]pathForResource:@"7.6M" ofType:@"mov"];
  132 + UISaveVideoAtPathToSavedPhotosAlbum(path, self, @selector(video:didFinishSavingWithError:contextInfo:), nil);
  133 + }
  134 +
  135 + // Demo使用本地AK、SK,真实环境这里需要实现http请求
  136 + self.uploadManager = [KS3UploadManager sharedInstanceWithClient:[KS3Client initialize] authHandler:nil];
  137 +}
  138 +
  139 +-(void)video:(NSString *)videoPath didFinishSavingWithError:(NSError *)error contextInfo:(void *)contextInfo{
  140 + if (error){
  141 + NSLog(@"本地保存失败");
  142 + }else {
  143 + NSLog(@"本地保存成功");
  144 + }
  145 +}
  146 +
  147 +- (void)deleteFinishedFile
  148 +{
  149 + NSString *strHost = [NSString stringWithFormat:@"http://%@.%@/%@", kDownloadBucketName,[[KS3Client initialize]getBucketDomain],kDownloadBucketKey];
  150 + NSString *filePath = [NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) firstObject];;
  151 + //文件临时文件地址,计算百分比
  152 + NSString * temporaryPath = [filePath stringByAppendingPathComponent: [NSString stringWithFormat:@"%@.%@",[strHost MD5Hash],@"pdf"]];
  153 + if ( [[NSFileManager defaultManager] removeItemAtPath:temporaryPath error:nil]) {
  154 + UIProgressView *progressView = (UIProgressView *)[self.view viewWithTag:99];
  155 + UIButton *stopBtn = (UIButton *)[self.view viewWithTag:100];
  156 + progressView.progress = 0;
  157 + [stopBtn setTitle:@"开始" forState:UIControlStateNormal];
  158 + stopBtn.selected = NO;
  159 + }else
  160 + {
  161 + NSLog(@"移除失败");
  162 + }
  163 +
  164 +
  165 +}
  166 +
  167 +#pragma mark TouchEvents
  168 +- (void)downloadBtnClicked:(UIButton *)btn
  169 +{
  170 +// if ([btn.titleLabel.text isEqualToString:@"完成"]) {
  171 +// NSLog(@"文件下载完成,请删除重试");
  172 +// return;
  173 +// }
  174 +
  175 + btn.selected =! btn.selected;
  176 + if (btn.selected ) {
  177 + [btn setTitle:@"暂停 " forState:UIControlStateNormal];
  178 + [self beginDownload];
  179 +
  180 + }else
  181 + {
  182 + [btn setTitle:@"继续 " forState:UIControlStateNormal];
  183 + [self stopDownload];
  184 + }
  185 +}
  186 +
  187 +- (void)uploadBtnClicked:(UIButton *)btn
  188 +{
  189 + btn.selected =! btn.selected;
  190 + if (btn.selected) {
  191 + [btn setTitle:@"暂停" forState:UIControlStateNormal];
  192 + [self beginMultipartUpload];
  193 + }else
  194 + {
  195 + if ([btn.titleLabel.text isEqualToString: @"完成" ]) {
  196 + UIProgressView *progressView = (UIProgressView *)[self.view viewWithTag:199];
  197 + progressView.progress = 0;
  198 + [btn setTitle:@"开始" forState:UIControlStateNormal];
  199 + return;
  200 + }
  201 + [_muilt pause];
  202 + [btn setTitle:@"继续" forState:UIControlStateNormal];
  203 + }
  204 +}
  205 +
  206 +#pragma mark 相册方法
  207 +
  208 +/*
  209 + 这里,枚举模拟器相册所有的视频,模拟器只有一个只能获得开头传入的7.6M视频,
  210 +具体工程使用时根据具体逻辑,获取到Alasset即可
  211 +KS3Client 方法:
  212 + - (NSData *)getUploadPartDataWithPartNum:(NSInteger)partNum
  213 + partLength:(NSInteger)partlength
  214 + alassetURL:(NSURL *)alassetURL;
  215 +
  216 +- (NSData *)getUploadPartDataWithPartNum:(NSInteger)partNum
  217 + partLength:(NSInteger)partlength
  218 + Alasset:(ALAsset *)assets;
  219 +
  220 +- (ALAsset *)getAlassetFromAlassetURL:(NSURL *)alassetURL;
  221 +
  222 + */
  223 +- (ALAsset *)getAlasset
  224 +{
  225 + ALAssetsLibrary *assetsLibrary = [[ALAssetsLibrary alloc]init];
  226 + __block ALAsset *assets ;
  227 + dispatch_semaphore_t sem= dispatch_semaphore_create(0);
  228 + dispatch_queue_t concurrentQueue = dispatch_queue_create("my.concurrent.queue", DISPATCH_QUEUE_SERIAL);
  229 + dispatch_async(concurrentQueue, ^{
  230 + [assetsLibrary enumerateGroupsWithTypes:ALAssetsGroupAll usingBlock:^(ALAssetsGroup *group, BOOL *stop) {
  231 + if (group) {
  232 + [group setAssetsFilter:[ALAssetsFilter allVideos]];
  233 + [group enumerateAssetsUsingBlock:^(ALAsset *result, NSUInteger index, BOOL *stop) {
  234 + if (result) {
  235 + assets = result;
  236 + NSLog(@"url = %@",assets.defaultRepresentation.url);
  237 + dispatch_semaphore_signal(sem);
  238 + return ;
  239 + }
  240 + }];
  241 + dispatch_semaphore_signal(sem);
  242 + }else
  243 + {
  244 + // NSLog(@"group为空,枚举失败");
  245 + }
  246 + dispatch_semaphore_signal(sem);
  247 + } failureBlock:^(NSError *error) {
  248 +
  249 + NSLog(@"请到设置->隐私->照片中开启,访问照片库的权限");
  250 + dispatch_semaphore_signal(sem);
  251 + }];
  252 + });
  253 +
  254 + dispatch_semaphore_wait(sem, DISPATCH_TIME_FOREVER);
  255 +
  256 + return assets;
  257 +}
  258 +
  259 +
  260 +#pragma mark 上传方法
  261 +
  262 +/*
  263 + 当文件大于100MB的时候,可以选择分块上传。把大文件进行切割上传到服务器。 分块上传分为三步:
  264 + Initiate Multipart Upload 初始化分块上传
  265 + Upload Part 上传文件块
  266 + Complete Multipart Upload 完成分块上传
  267 + 上传中,你可以使用Abort Multipart Upload取消上传,或者List Parts查看上传的分块。或者List Multipart Uploads查看当前的bucket下有多少个uploadid。
  268 +
  269 + 分块上传断点续传原理:
  270 + 上传为了简化流程的复杂度,每次都是从初始化从头开始,依步骤进行:
  271 + 1.初始化上传,发initMultiUpload请求,并记录uploadId,如果已存在uploadID,用已经存在的uploadID,进行第二步
  272 + 2.分块上传数据块,一块一块串行的发uploadPart请求,直至所有块传输成功。若中间断开,从第一步重新开始。
  273 + 3.完成上传,发complete请求,httpCode = 200,成功
  274 +
  275 + Tips:1.基于分块上传的原理,上传暂停继续会有最多一个块的进度回退。
  276 + 2.分块上传最小为5M一块,小于5M请使用单块上传,Put Object方法
  277 +
  278 + */
  279 +- (void)beginMultipartUpload
  280 +{
  281 + NSString *strKey = kUploadBucketKey; //key 为在bucket下的路径,demo中为根目录下7.6M.mov路径
  282 + _partSize = 5; // 文件大于5M为最小5M一块
  283 +
  284 + KS3AccessControlList *acl = [[KS3AccessControlList alloc] init];
  285 + [acl setContronAccess:KingSoftYun_Permission_Public_Read];
  286 +
  287 + KS3InitiateMultipartUploadRequest *initMultipartUploadReq = [[KS3InitiateMultipartUploadRequest alloc] initWithKey:strKey inBucket:kUploadBucketName acl:acl grantAcl:nil];
  288 + [initMultipartUploadReq setCompleteRequest];
  289 +
  290 +#warning 1.使用token签名时从Appserver获取token后设置token,这里用token方式依然用到AKSK是为了模拟从服务器获取Token 2.使用Ak sk则忽略,不需要调用
  291 +// [initMultipartUploadReq setStrKS3Token:[KS3Util getAuthorization:initMultipartUploadReq]];
  292 + NSArray *array = [initMultipartUploadReq.kSYHeader componentsSeparatedByString:@"\n"];
  293 + NSString *headers = [array firstObject];
  294 +
  295 +// [CNLiveCommonTools ksgetRealTimeString:^(NSString *timeString, NSDate *date) {
  296 +//
  297 +// NSMutableDictionary *parameter = [@{@"appId":@"60_j5xilfyl12",
  298 +// @"verb":initMultipartUploadReq.httpMethod,
  299 +// @"md5":initMultipartUploadReq.contentMd5,
  300 +// @"type":initMultipartUploadReq.contentType,
  301 +// @"res":initMultipartUploadReq.kSYResource,
  302 +// @"date":initMultipartUploadReq.strDate,
  303 +// @"headers":verb,
  304 +// @"platform_id":[NSBundle mainBundle].bundleIdentifier,
  305 +// @"timestamp":timeString} copy];
  306 +//
  307 +// NSLog(@"------------%@", parameter);
  308 +//
  309 +// NSMutableDictionary *para = [CNLiveCommonTools ksencryptionSignWithParameter:parameter];
  310 +// [[CNLiveNetManager manager] requestPostURL:@"http://test.open.cnlive.com/openapi/api2/vod_epg/getKs3AuthForApp" parameters:para success:^(NSURLResponse * _Nullable response, id _Nullable responseObject) {
  311 +// if (responseObject[@"errorCode"] && [responseObject[@"errorCode"]isEqualToString:@"0"]) {
  312 +//
  313 +// NSString *jsonStr = [responseObject objectForKey:@"data"];
  314 +// NSData *data = [jsonStr dataUsingEncoding:NSUTF8StringEncoding];
  315 +// NSDictionary *dic = [NSJSONSerialization JSONObjectWithData:data options:NSJSONReadingMutableLeaves error:nil];
  316 +// NSLog(@"sucee: %@",dic);
  317 +// }
  318 +// } failure:^(NSURLResponse * _Nullable response, NSError * _Nullable error) {
  319 +// NSDictionary *errorDic = @{@"errorCode":[NSString stringWithFormat:@"%d",error.code],
  320 +// @"errorMessage": error.localizedDescription};
  321 +// NSLog(@"error: %@",errorDic);
  322 +//
  323 +// }];
  324 +// }];
  325 +
  326 +
  327 + [CNLiveUpload getAuthDicWithMd5:initMultipartUploadReq.contentMd5 verb:initMultipartUploadReq.httpMethod type:initMultipartUploadReq.contentType res:initMultipartUploadReq.kSYResource headers:headers date:initMultipartUploadReq.strDate success:^(NSDictionary *dic) {
  328 + [initMultipartUploadReq setStrKS3Token:dic[@"Authorization"]];
  329 +// [initMultipartUploadReq setStrDate:dic[@"data"][@"Date"]];
  330 + NSLog(@"dic %@",dic);
  331 +
  332 + _muilt = [[KS3Client initialize] initiateMultipartUploadWithRequest:initMultipartUploadReq];
  333 +
  334 +
  335 + if (_muilt == nil) {
  336 + NSLog(@"####Init upload failed, please check access key, secret key and bucket name!####");
  337 + return ;
  338 + }
  339 +#warning 选择相册还是普通方式
  340 + _muilt.uploadType = kUploadNormal;
  341 +
  342 + //根据文件路径不一样,有如下两种上传
  343 + if (_muilt.uploadType == kUploadNormal) { //如果是沙盒或者工程里的文件
  344 + //工程里,沙盒里,是沙盒路径
  345 + NSString *strFilePath = [[NSBundle mainBundle] pathForResource:@"7.6M" ofType:@"mov"];
  346 + _fileHandle = [NSFileHandle fileHandleForReadingAtPath:strFilePath];
  347 + _fileSize = [_fileHandle availableData].length;
  348 + if (_fileSize <= 0) {
  349 + NSLog(@"####This file is not exist!####");
  350 + return ;
  351 + }
  352 + if (!(_partSize > 0 || _partSize != 0)) {
  353 + _partLength = _fileSize;
  354 + }else{
  355 + _partLength = _partSize * 1024.0 * 1024.0;
  356 + }
  357 + _totalNum = (ceilf((float)_fileSize / (float)_partLength));
  358 + [_fileHandle seekToFileOffset:0];
  359 + }else
  360 + {
  361 + //如果是相册里的,从这传
  362 + ALAssetRepresentation *assetD = [self getAlasset].defaultRepresentation;
  363 + _fileSize = assetD.size;
  364 + if (_fileSize <= 0) {
  365 + NSLog(@"####This file is not exist!####");
  366 + return ;
  367 + }
  368 + if (!(_partSize > 0 || _partSize != 0)) {
  369 + _partLength = _fileSize;
  370 + }else{
  371 + _partLength = _partSize * 1024.0 * 1024.0;
  372 + }
  373 + _totalNum = (ceilf((float)_fileSize / (float)_partLength));
  374 + }
  375 +
  376 +
  377 +#warning 上传的断点续传判断:初始化上传后,开始上传前,此处需要list一下所有的数据块,如果uploadID是新生成的,可以跳过list过程从第一块开始传,如果上传是断点续传,需用初始化用到的uploadId,list一下所有已经传过的数据块,再从暂停块上传即可, 这里用NSUserDefault演示存储过程。
  378 + //判断uploadId是否存在,进而进行上传的断点续传
  379 + if ([mUserDefaults objectForKey:keyUploadId] == nil) {
  380 + [mUserDefaults setObject:_muilt.uploadId forKey:keyUploadId];
  381 + [mUserDefaults synchronize];
  382 + _uploadNum = 1;
  383 + [self uploadWithPartNumber:_uploadNum];
  384 + }else
  385 + {
  386 + _muilt.uploadId = [mUserDefaults objectForKey:keyUploadId];
  387 + //list一下所有上传过的块
  388 + KS3ListPartsRequest *req2 = [[KS3ListPartsRequest alloc] initWithMultipartUpload:_muilt];
  389 + [req2 setCompleteRequest];
  390 +
  391 + //使用token签名时从Appserver获取token后设置token,使用Ak sk则忽略,不需要调用
  392 + [req2 setStrKS3Token:dic[@"Authorization"]];
  393 +
  394 + KS3ListPartsResponse *response2 = [[KS3Client initialize] listParts:req2];
  395 +
  396 + NSLog(@"response.listResult.parts.count =%lu",(unsigned long)[response2.listResult.parts count]);
  397 +
  398 + //从这块开始上传,list结果的最后一块
  399 + _uploadNum = ((KS3Part *)[response2.listResult.parts lastObject]).partNumber + 1 ;
  400 +
  401 + //进度补齐
  402 + long long alreadyTotalWriten = (_uploadNum - 1) * _partLength ;
  403 + double progress = alreadyTotalWriten / (float)_fileSize;
  404 + UIProgressView *progressView = (UIProgressView *)[self.view viewWithTag:199];
  405 + progressView.progress = progress;
  406 + [self uploadWithPartNumber:_uploadNum];
  407 +
  408 + }
  409 + } failure:^(NSDictionary *error) {
  410 + NSLog(@"error %@",error);
  411 + }];
  412 +
  413 + //initMultipartUploadReq.strDate = @"Fri, 15 Jul 2016 09:21:30 GMT";
  414 + //initMultipartUploadReq.strKS3Token = @"KSS JYWSSnN5qY/hFiWg/Y1V:s1ICTedN7C+QqGFMD1FQYj6/bYA=";
  415 +
  416 +
  417 +}
  418 +
  419 +
  420 +- (void)uploadWithPartNumber:(NSInteger)partNumber
  421 +{
  422 + @autoreleasepool {
  423 + //如果暂停,恢复上传
  424 + if (_muilt.isPaused == YES || _muilt.isCanceled == YES ) {
  425 + [_muilt proceed];
  426 + }
  427 + NSData *data = nil;
  428 + if (_muilt.uploadType == kUploadAlasset) {
  429 + //相册信息
  430 + data = [[KS3Client initialize] getUploadPartDataWithPartNum:partNumber partLength:FileBlockSize Alasset:[self getAlasset]];
  431 + }else
  432 + {
  433 + //沙盒路径
  434 +
  435 + if (_uploadNum == _totalNum) {
  436 + [_fileHandle seekToFileOffset:_partLength *(_uploadNum - 1 )];
  437 + data = [_fileHandle readDataToEndOfFile];
  438 + }else {
  439 + data = [_fileHandle readDataOfLength:(NSUInteger)_partLength];
  440 + [_fileHandle seekToFileOffset:_partLength*(_uploadNum)];
  441 + }
  442 + }
  443 +
  444 + KS3UploadPartRequest *req = [[KS3UploadPartRequest alloc] initWithMultipartUpload:_muilt partNumber:(int32_t)partNumber data:data generateMD5:NO];
  445 + req.delegate = self;
  446 + req.contentLength = data.length;
  447 + req.contentMd5 = [KS3SDKUtil base64md5FromData:data];
  448 + [req setCompleteRequest];
  449 +
  450 + NSArray *array = [req.kSYHeader componentsSeparatedByString:@"\n"];
  451 + NSString *headers = [array firstObject];
  452 + [CNLiveUpload getAuthDicWithMd5:req.contentMd5 verb:req.httpMethod type:req.contentType res:req.kSYResource headers:headers date:req.strDate success:^(NSDictionary *dic) {
  453 + //使用token签名时从Appserver获取token后设置token,使用Ak sk则忽略,不需要调用
  454 + [req setStrKS3Token:dic[@"Authorization"]];
  455 +
  456 + [[KS3Client initialize] uploadPart:req];
  457 + }failure:^(NSDictionary *error) {
  458 + NSLog(@"error %@",error);
  459 + }];
  460 + }
  461 +}
  462 +//取消上传,调用abort 接口,终止上传,修改进度条即可
  463 +- (void)cancelMultipartUpload
  464 +{
  465 + if (_muilt == nil) {
  466 + NSLog(@"请先创建上传,再调用Abort");
  467 + return;
  468 + }
  469 +
  470 +
  471 + KS3AbortMultipartUploadRequest *request = [[KS3AbortMultipartUploadRequest alloc] initWithMultipartUpload:_muilt];
  472 + [request setCompleteRequest];
  473 +
  474 + NSArray *array = [request.kSYHeader componentsSeparatedByString:@"\n"];
  475 + NSString *headers = [array firstObject];
  476 + [CNLiveUpload getAuthDicWithMd5:request.contentMd5 verb:request.httpMethod type:request.contentType res:request.kSYResource headers:headers date:request.strDate success:^(NSDictionary *dic) {
  477 + //使用token签名时从Appserver获取token后设置token,使用Ak sk则忽略,不需要调用
  478 + [request setStrKS3Token:dic[@"Authorization"]];
  479 +
  480 + KS3AbortMultipartUploadResponse *response = [[KS3Client initialize] abortMultipartUpload:request];
  481 +
  482 + if (response.httpStatusCode == 204) {
  483 + NSLog(@"Abort multipart upload success!");
  484 + [_muilt cancel];
  485 + [mUserDefaults setObject:nil forKey:keyUploadId];
  486 + [mUserDefaults setInteger:0 forKey:keyUploadPartNum];
  487 + [mUserDefaults synchronize];
  488 + UIProgressView *progressView = (UIProgressView *)[self.view viewWithTag:199];
  489 + progressView.progress = 0;
  490 +
  491 + }
  492 + else {
  493 + NSLog(@"error: %@", response.error.description);
  494 + }
  495 + }failure:^(NSDictionary *error) {
  496 + NSLog(@"error %@",error);
  497 + }];
  498 +}
  499 +
  500 +//若不选择分块上传,请使用单块上传,
  501 +//最小支持但块上传小于5M,最大支持单块上传为5G
  502 +- (void)beginSingleUpload:(NSInteger) row
  503 +{
  504 + KS3AccessControlList *ControlList = [[KS3AccessControlList alloc] init];
  505 + [ControlList setContronAccess:KingSoftYun_Permission_Public_Read_Write];
  506 +// KS3GrantAccessControlList *acl = [[KS3GrantAccessControlList alloc] init];
  507 +// // acl.identifier = @"4567894346";
  508 +// // acl.displayName = @"accDisplayName";
  509 +// [acl setGrantControlAccess:KingSoftYun_Grant_Permission_Read];
  510 + KS3PutObjectRequest *putObjRequest = [[KS3PutObjectRequest alloc] initWithName:kUploadBucketName withAcl:ControlList grantAcl:nil];
  511 +
  512 + if (row == 3) {
  513 + NSString *fileName = [[NSBundle mainBundle] pathForResource:@"7.6M" ofType:@"mov"];
  514 + putObjRequest.data = [NSData dataWithContentsOfFile:fileName options:NSDataReadingMappedIfSafe error:nil];
  515 + } else {
  516 + NSInteger size = 1;
  517 + if (row == 13) {
  518 + size = 1;
  519 + } else if (row == 14) {
  520 + size = 5;
  521 + } else if (row == 15) {
  522 + size = 10;
  523 + } else {
  524 + size = 50;
  525 + }
  526 +
  527 + putObjRequest.data = [[NSMutableData dataWithLength:size * 1024 * 1024] copy];
  528 + }
  529 +
  530 + _fileSize = putObjRequest.data.length;
  531 +
  532 + putObjRequest.delegate = self;
  533 + putObjRequest.filename = kUploadBucketKey;//[fileName lastPathComponent];
  534 + // putObjRequest.callbackUrl = @"http://123.59.36.81/index.php/api/photos/callback";
  535 + // putObjRequest.callbackBody = @"location=${kss-location}&name=${kss-name}&uid=8888";
  536 + // putObjRequest.callbackParams = @{@"kss-location": @"china_location", @"kss-name": @"lulu_name"};+
  537 + putObjRequest.contentMd5 = [KS3SDKUtil base64md5FromData:putObjRequest.data];
  538 + [putObjRequest setCompleteRequest];
  539 +
  540 + NSArray *array = [putObjRequest.kSYHeader componentsSeparatedByString:@"\n"];
  541 + NSString *headers = [array firstObject];
  542 + [CNLiveUpload getAuthDicWithMd5:putObjRequest.contentMd5 verb:putObjRequest.httpMethod type:putObjRequest.contentType res:putObjRequest.kSYResource headers:headers date:putObjRequest.strDate success:^(NSDictionary *dic) {
  543 + //使用token签名时从Appserver获取token后设置token,使用Ak sk则忽略,不需要调用
  544 + [putObjRequest setStrKS3Token:dic[@"Authorization"]];
  545 + [putObjRequest setStrDate:dic[@"Date"]];
  546 + dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(5 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
  547 + KS3PutObjectResponse *response = [[KS3Client initialize] putObject:putObjRequest];
  548 +
  549 + //putObjRequest若没设置代理,则是同步的下方判断,
  550 + //putObjRequest若设置了代理,则走上传代理回调,
  551 + if (putObjRequest.delegate == nil) {
  552 + NSLog(@"%@",[[NSString alloc] initWithData:response.body encoding:NSUTF8StringEncoding]);
  553 + if (response.httpStatusCode == 200) {
  554 + NSLog(@"Put object success");
  555 + }
  556 + else {
  557 + NSLog(@"Put object failed");
  558 + }
  559 + }
  560 + });
  561 + }failure:^(NSDictionary *error) {
  562 + NSLog(@"error %@",error);
  563 + }];
  564 +
  565 +// NSArray *array = [putObjRequest.kSYHeader componentsSeparatedByString:@"\n"];
  566 +// NSString *verb = [array firstObject];
  567 +//
  568 +// [CNLiveCommonTools ksgetRealTimeString:^(NSString *timeString, NSDate *date) {
  569 +//
  570 +// NSMutableDictionary *parameter = [@{@"appId":@"60_j5xilfyl12",
  571 +// @"verb":putObjRequest.httpMethod,
  572 +// @"md5":putObjRequest.contentMd5,
  573 +// @"type":putObjRequest.contentType,
  574 +// @"res":putObjRequest.kSYResource,
  575 +// @"date":putObjRequest.strDate,
  576 +// @"headers":verb,
  577 +// @"platform_id":[NSBundle mainBundle].bundleIdentifier,
  578 +// @"timestamp":timeString} copy];
  579 +//
  580 +// NSLog(@"------------%@", parameter);
  581 +//
  582 +// NSMutableDictionary *para = [CNLiveCommonTools ksencryptionSignWithParameter:parameter];
  583 +// [[CNLiveNetManager manager] requestPostURL:@"http://test.open.cnlive.com/openapi/api2/vod_epg/getKs3AuthForApp" parameters:para success:^(NSURLResponse * _Nullable response, id _Nullable responseObject) {
  584 +// if (responseObject[@"errorCode"] && [responseObject[@"errorCode"]isEqualToString:@"0"]) {
  585 +//
  586 +// NSString *jsonStr = [responseObject objectForKey:@"data"];
  587 +// NSData *data = [jsonStr dataUsingEncoding:NSUTF8StringEncoding];
  588 +// NSDictionary *dic = [NSJSONSerialization JSONObjectWithData:data options:NSJSONReadingMutableLeaves error:nil];
  589 +// NSLog(@"sucee: %@",dic);
  590 +// [putObjRequest setStrKS3Token:dic[@"Authorization"]];
  591 +// [putObjRequest setStrDate:dic[@"Date"]];
  592 +// }
  593 +// } failure:^(NSURLResponse * _Nullable response, NSError * _Nullable error) {
  594 +// NSDictionary *errorDic = @{@"errorCode":[NSString stringWithFormat:@"%zd",error.code],
  595 +// @"errorMessage": error.localizedDescription};
  596 +// NSLog(@"error: %@",errorDic);
  597 +//
  598 +// }];
  599 +// }];
  600 +//
  601 +// dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(5 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
  602 +// KS3PutObjectResponse *response = [[KS3Client initialize] putObject:putObjRequest];
  603 +//
  604 +//
  605 +// //putObjRequest若没设置代理,则是同步的下方判断,
  606 +// //putObjRequest若设置了代理,则走上传代理回调,
  607 +// if (putObjRequest.delegate == nil) {
  608 +// NSLog(@"%@",[[NSString alloc] initWithData:response.body encoding:NSUTF8StringEncoding]);
  609 +// if (response.httpStatusCode == 200) {
  610 +// NSLog(@"Put object success");
  611 +// }
  612 +// else {
  613 +// NSLog(@"Put object failed");
  614 +// }
  615 +// }
  616 +// });
  617 +}
  618 +
  619 +#pragma mark 下载方法
  620 +
  621 +/*开始下载,
  622 + 1.如果本地文件已存在,则下载完成
  623 + 2.本地文件不存在,从0下载
  624 + 3.本地有临时下载文件,则从原先进度继续下载
  625 + */
  626 +- (void)beginDownload
  627 +{
  628 + UIProgressView *progressView = (UIProgressView *)[self.view viewWithTag:99];
  629 + UIButton *stopBtn = (UIButton *)[self.view viewWithTag:100];
  630 + /**
  631 + * 如果是暂停下载,就需要把_downloadConnection的file做为参数传到download方法里面
  632 + */
  633 + dispatch_queue_t concurrentQueue = dispatch_queue_create("my.concurrent.queue", DISPATCH_QUEUE_SERIAL);
  634 +
  635 + dispatch_async(concurrentQueue, ^(){
  636 + _downloader = [[KS3Client initialize] downloadObjectWithBucketName:kDownloadBucketName key:kDownloadBucketKey downloadBeginBlock:^(KS3DownLoad *aDownload, NSURLResponse *responseHeaders) {
  637 + NSLog(@"开始下载,responseHeaders:%@",responseHeaders);
  638 +
  639 + } downloadFileCompleteion:^(KS3DownLoad *aDownload, NSString *filePath) {
  640 + dispatch_async(dispatch_get_main_queue(), ^{
  641 + [stopBtn setTitle:@"完成" forState:UIControlStateNormal];
  642 + NSLog(@"completed, file path: %@", filePath);
  643 + });
  644 + } downloadProgressChangeBlock:^(KS3DownLoad *aDownload, double newProgress) {
  645 + dispatch_async(dispatch_get_main_queue(), ^{
  646 + progressView.progress = newProgress;
  647 + NSLog(@"progress: %f", newProgress);
  648 + });
  649 +
  650 +
  651 + } failedBlock:^(KS3DownLoad *aDownload, NSError *error) {
  652 + NSLog(@"failed: %@", error.description);
  653 + }];
  654 +
  655 + NSArray *array = [_downloader.kSYHeader componentsSeparatedByString:@"\n"];
  656 + NSString *headers = [array firstObject];
  657 + [CNLiveUpload getAuthDicWithMd5:_downloader.contentMd5 verb:_downloader.httpMethod type:_downloader.contentType res:_downloader.kSYResource headers:headers date:_downloader.strDate success:^(NSDictionary *dic) {
  658 + //使用token签名时从Appserver获取token后设置token,使用Ak sk则忽略,不需要调用
  659 + [_downloader setStrKS3Token:dic[@"Authorization"]];
  660 +
  661 + _downloader.overwrite = YES;
  662 +
  663 + [_downloader start];
  664 +
  665 + }failure:^(NSDictionary *error) {
  666 + NSLog(@"error %@",error);
  667 + }];
  668 + });
  669 +
  670 +}
  671 +
  672 +//暂停下载,支持断点续传,下次开启程序,进度条的恢复需要计算一下,demo里define kDownloadSize了文件大小
  673 +- (void)stopDownload
  674 +{
  675 + [_downloader stop];
  676 +}
  677 +
  678 +- (void)uploadWithUploadManager {
  679 + NSString *strFilePath = [[NSBundle mainBundle] pathForResource:@"7.6M" ofType:@"mov"];
  680 + NSData *data = [NSData dataWithContentsOfFile:strFilePath];
  681 +
  682 + KS3AccessControlList *acl = [[KS3AccessControlList alloc] init];
  683 + [acl setContronAccess:KingSoftYun_Permission_Public_Read];
  684 +
  685 + KS3UploadRequest *uploadRequest = [[KS3UploadRequest alloc] initWithKey:@"uploadmanager/sample.mov" inBucket:kUploadBucketName acl:acl grantAcl:nil];
  686 + [uploadRequest setCompleteRequest];
  687 +
  688 + NSArray *array = [uploadRequest.kSYHeader componentsSeparatedByString:@"\n"];
  689 + NSString *headers = [array firstObject];
  690 + [CNLiveUpload getAuthDicWithMd5:uploadRequest.contentMd5 verb:uploadRequest.httpMethod type:uploadRequest.contentType res:uploadRequest.kSYResource headers:headers date:uploadRequest.strDate success:^(NSDictionary *dic) {
  691 + //使用token签名时从Appserver获取token后设置token,使用Ak sk则忽略,不需要调用
  692 + [uploadRequest setStrKS3Token:dic[@"Authorization"]];
  693 +
  694 + [self.uploadManager putData:data
  695 + request:uploadRequest
  696 + blockSize:1 * kMB
  697 + progress:^(NSString *key, double percent) {
  698 + NSLog(@"objectKey: %@, progress %lf", key, percent);
  699 + } cancelSignal:^BOOL(NSString *key) {
  700 + return false; // 修改这里进行取消
  701 + } complete:^(KS3Upload *upload, KS3Response *response) {
  702 + NSLog(@"uploadId: %@, response %@", upload.uploadId, response);
  703 + } error:^(KS3Upload *upload, NSError *error) {
  704 + NSLog(@"uploadId: %@, error: %@", upload.uploadId, error);
  705 + }];
  706 + }failure:^(NSDictionary *error) {
  707 + NSLog(@"error %@",error);
  708 + }];
  709 +}
  710 +
  711 +#pragma mark - UITableView datasource
  712 +- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
  713 +{
  714 + return _arrItems.count;
  715 +}
  716 +
  717 +- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
  718 +{
  719 + NSString *strIdentifier = @"bucket identifier";
  720 + UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:strIdentifier];
  721 + if (nil == cell) {
  722 + cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:strIdentifier];
  723 + if (indexPath.row == 0) { //Get Object下载
  724 + UIProgressView *progressView = [[UIProgressView alloc] initWithFrame:CGRectMake(mScreenWidth * .35 , 20, mScreenWidth * .5, 20)];
  725 + progressView.progressViewStyle = UIProgressViewStyleDefault;
  726 + progressView.tag = 99;
  727 +
  728 + //计算下载临时文件的大小,临时文件是经过MD5Hash的文件名
  729 + NSString *strHost = [NSString stringWithFormat:@"http://%@.%@/%@", kDownloadBucketName, [[KS3Client initialize]getBucketDomain],kDownloadBucketKey];
  730 + NSString *filePath = [NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) firstObject];;
  731 + //文件临时文件地址,计算百分比
  732 + NSString * temporaryPath=[filePath stringByAppendingPathComponent: [strHost MD5Hash]];
  733 + NSFileHandle * fileHandle = [NSFileHandle fileHandleForWritingAtPath:temporaryPath];
  734 + unsigned long long offset = [fileHandle seekToEndOfFile];
  735 + progressView.progress = offset * 1.0 / kDownloadSize;
  736 + [cell.contentView addSubview:progressView];
  737 +
  738 + UIButton *stopBtn = [[UIButton alloc]initWithFrame:CGRectMake(mScreenWidth - 50, 10, 40, 20)];
  739 + [stopBtn setTitle:@"开始" forState:UIControlStateNormal];
  740 + stopBtn.titleLabel.font = [UIFont systemFontOfSize:14];
  741 + [stopBtn setTitleColor:[UIColor blueColor] forState:UIControlStateNormal];
  742 + stopBtn .tag = 100;
  743 + [stopBtn addTarget:self action:@selector(downloadBtnClicked:) forControlEvents:UIControlEventTouchUpInside];
  744 + [cell.contentView addSubview:stopBtn];
  745 +
  746 + }
  747 + if (indexPath.row == 9) { //分块上传
  748 + UIProgressView *progressView = [[UIProgressView alloc] initWithFrame:CGRectMake(mScreenWidth * .4 , 20, mScreenWidth * .45, 20)];
  749 + progressView.progressViewStyle = UIProgressViewStyleDefault;
  750 + progressView.tag = 199;
  751 + NSInteger finishCount = [mUserDefaults integerForKey:keyUploadPartNum];
  752 +
  753 + progressView.progress = finishCount * FileBlockSize * 1.0 / _fileSize;
  754 + [cell.contentView addSubview:progressView];
  755 +
  756 + UIButton *uploadBtn = [[UIButton alloc]initWithFrame:CGRectMake(mScreenWidth - 50, 10, 40, 20)];
  757 + [uploadBtn setTitle:@"开始" forState:UIControlStateNormal];
  758 + uploadBtn.titleLabel.font = [UIFont systemFontOfSize:14];
  759 + [uploadBtn setTitleColor:[UIColor blueColor] forState:UIControlStateNormal];
  760 + uploadBtn .tag = 200;
  761 + [uploadBtn addTarget:self action:@selector(uploadBtnClicked:) forControlEvents:UIControlEventTouchUpInside];
  762 + [cell.contentView addSubview:uploadBtn];
  763 + }
  764 +
  765 +// if (indexPath.row == 12) { // UploadManager上传
  766 +// UIProgressView *progressView = [[UIProgressView alloc] initWithFrame:CGRectMake(mScreenWidth * .4 , 20, mScreenWidth * .45, 20)];
  767 +// progressView.progressViewStyle = UIProgressViewStyleDefault;
  768 +// progressView.tag = 299;
  769 +//
  770 +// progressView.progress = 0;
  771 +// [cell.contentView addSubview:progressView];
  772 +//
  773 +// UIButton *uploadBtn = [[UIButton alloc]initWithFrame:CGRectMake(mScreenWidth - 50, 10, 40, 20)];
  774 +// [uploadBtn setTitle:@"开始" forState:UIControlStateNormal];
  775 +// uploadBtn.titleLabel.font = [UIFont systemFontOfSize:14];
  776 +// [uploadBtn setTitleColor:[UIColor blueColor] forState:UIControlStateNormal];
  777 +// uploadBtn .tag = 200;
  778 +// [uploadBtn addTarget:self action:@selector(uploadBtnClicked:) forControlEvents:UIControlEventTouchUpInside];
  779 +// [cell.contentView addSubview:uploadBtn];
  780 +// }
  781 + }
  782 + cell.textLabel.text = _arrItems[indexPath.row];
  783 + return cell;
  784 +}
  785 +
  786 +#pragma mark - UITableView delegate
  787 +- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
  788 +{
  789 + switch (indexPath.row) {
  790 + case 0:
  791 + {
  792 + //放在点击事件里,downloadBtnClicked
  793 +
  794 + }
  795 + break;
  796 + case 1:
  797 + {
  798 + KS3DeleteObjectRequest *deleteObjRequest = [[KS3DeleteObjectRequest alloc] initWithName:kBucketName withKeyName:kObjectSpecial1];
  799 + [deleteObjRequest setCompleteRequest];
  800 +
  801 + NSArray *array = [deleteObjRequest.kSYHeader componentsSeparatedByString:@"\n"];
  802 + NSString *headers = [array firstObject];
  803 + [CNLiveUpload getAuthDicWithMd5:deleteObjRequest.contentMd5 verb:deleteObjRequest.httpMethod type:deleteObjRequest.contentType res:deleteObjRequest.kSYResource headers:headers date:deleteObjRequest.strDate success:^(NSDictionary *dic) {
  804 + //使用token签名时从Appserver获取token后设置token,使用Ak sk则忽略,不需要调用
  805 + [deleteObjRequest setStrKS3Token:dic[@"Authorization"]];
  806 + KS3DeleteObjectResponse *response = [[KS3Client initialize] deleteObject:deleteObjRequest];
  807 + if (response.httpStatusCode == 204) {
  808 + NSLog(@"Delete object success!");
  809 + }
  810 + else {
  811 + NSLog(@"Delete object error: %@", response.error.description);
  812 + }
  813 + }failure:^(NSDictionary *error) {
  814 + NSLog(@"error %@",error);
  815 + }];
  816 + }
  817 + break;
  818 + case 2:
  819 + {
  820 + KS3HeadObjectRequest *headObjRequest = [[KS3HeadObjectRequest alloc] initWithName:kBucketName withKeyName:kObjectSpecial2];
  821 + [headObjRequest setCompleteRequest];
  822 +
  823 + NSArray *array = [headObjRequest.kSYHeader componentsSeparatedByString:@"\n"];
  824 + NSString *headers = [array firstObject];
  825 + [CNLiveUpload getAuthDicWithMd5:headObjRequest.contentMd5 verb:headObjRequest.httpMethod type:headObjRequest.contentType res:headObjRequest.kSYResource headers:headers date:headObjRequest.strDate success:^(NSDictionary *dic) {
  826 + //使用token签名时从Appserver获取token后设置token,使用Ak sk则忽略,不需要调用
  827 + [headObjRequest setStrKS3Token:dic[@"Authorization"]];
  828 +
  829 + KS3HeadObjectResponse *response = [[KS3Client initialize] headObject:headObjRequest];
  830 + if (response.httpStatusCode == 200) {
  831 + NSLog(@"Head object success!");
  832 + }
  833 + else {
  834 + NSLog(@"Head object error: %@", response.error.description);
  835 + }
  836 + }failure:^(NSDictionary *error) {
  837 + NSLog(@"error %@",error);
  838 + }];
  839 + }
  840 + break;
  841 + case 3:
  842 + case 13:
  843 + case 14:
  844 + case 15:
  845 + case 16:
  846 + {
  847 + [self beginSingleUpload: indexPath.row];
  848 + }
  849 + break;
  850 + case 4:
  851 + {
  852 + KS3BucketObject *destBucketObj = [[KS3BucketObject alloc] initWithBucketName:kDesBucketName keyName:@"111111111 a b + - * ~ ! @ # ^ :中 ~ 文.jpg"];
  853 + KS3BucketObject *sourceBucketObj = [[KS3BucketObject alloc] initWithBucketName:kBucketName keyName:@"1111 a b + - * ~ ! @ # ^ :中 ~ 文.jpg"];
  854 + KS3PutObjectCopyRequest *request = [[KS3PutObjectCopyRequest alloc] initWithName:destBucketObj sourceBucketObj:sourceBucketObj];
  855 + [request setCompleteRequest];
  856 +
  857 + NSArray *array = [request.kSYHeader componentsSeparatedByString:@"\n"];
  858 + NSString *headers = [array firstObject];
  859 + [CNLiveUpload getAuthDicWithMd5:request.contentMd5 verb:request.httpMethod type:request.contentType res:request.kSYResource headers:headers date:request.strDate success:^(NSDictionary *dic) {
  860 + //使用token签名时从Appserver获取token后设置token,使用Ak sk则忽略,不需要调用
  861 + [request setStrKS3Token:dic[@"Authorization"]];
  862 + KS3PutObjectCopyResponse *response = [[KS3Client initialize] putObjectCopy:request];
  863 + if (response.httpStatusCode == 200) {
  864 + NSLog(@"Put object copy success!");
  865 + }
  866 + else {
  867 + NSLog(@"Put object copy error: %@", response.error.description);
  868 + }
  869 + }failure:^(NSDictionary *error) {
  870 + NSLog(@"error %@",error);
  871 + }];
  872 + }
  873 + break;
  874 + case 5:
  875 + {
  876 + NSLog(@"暂不对移动端开放!");
  877 + }
  878 + break;
  879 + case 6:
  880 + {
  881 + KS3GetObjectACLRequest *getObjectACLRequest = [[KS3GetObjectACLRequest alloc] initWithName:kBucketName withKeyName:kObjectSpecial2];
  882 + [getObjectACLRequest setCompleteRequest];
  883 +
  884 + NSArray *array = [getObjectACLRequest.kSYHeader componentsSeparatedByString:@"\n"];
  885 + NSString *headers = [array firstObject];
  886 + [CNLiveUpload getAuthDicWithMd5:getObjectACLRequest.contentMd5 verb:getObjectACLRequest.httpMethod type:getObjectACLRequest.contentType res:getObjectACLRequest.kSYResource headers:headers date:getObjectACLRequest.strDate success:^(NSDictionary *dic) {
  887 + //使用token签名时从Appserver获取token后设置token,使用Ak sk则忽略,不需要调用
  888 + [getObjectACLRequest setStrKS3Token:dic[@"Authorization"]];
  889 + KS3GetObjectACLResponse *response = [[KS3Client initialize] getObjectACL:getObjectACLRequest];
  890 + KS3BucketACLResult *result = response.listBucketsResult;
  891 +
  892 + if (response.httpStatusCode == 200) {
  893 + NSLog(@"Get object acl success!");
  894 + NSLog(@"Object owner ID: %@",result.owner.ID);
  895 + NSLog(@"Object owner displayName: %@",result.owner.displayName);
  896 + for (KS3Grant *grant in result.accessControlList) {
  897 + NSLog(@"%@",grant.grantee.ID);
  898 + NSLog(@"%@",grant.grantee.displayName);
  899 + NSLog(@"%@",grant.grantee.URI);
  900 + NSLog(@"_______________________");
  901 + NSLog(@"%@",grant.permission);
  902 + }
  903 + }
  904 + else {
  905 + NSLog(@"Get object acl error: %@", response.error.description);
  906 + }
  907 + }failure:^(NSDictionary *error) {
  908 + NSLog(@"error %@",error);
  909 + }];
  910 + }
  911 + break;
  912 + case 7:
  913 + {
  914 + KS3AccessControlList *acl = [[KS3AccessControlList alloc] init];
  915 + [acl setContronAccess:KingSoftYun_Permission_Public_Read_Write];
  916 + KS3SetObjectACLRequest *setObjectACLRequest = [[KS3SetObjectACLRequest alloc] initWithName:kBucketName withKeyName:kObjectSpecial2 acl:acl];
  917 + [setObjectACLRequest setCompleteRequest];
  918 +
  919 + NSArray *array = [setObjectACLRequest.kSYHeader componentsSeparatedByString:@"\n"];
  920 + NSString *headers = [array firstObject];
  921 + [CNLiveUpload getAuthDicWithMd5:setObjectACLRequest.contentMd5 verb:setObjectACLRequest.httpMethod type:setObjectACLRequest.contentType res:setObjectACLRequest.kSYResource headers:headers date:setObjectACLRequest.strDate success:^(NSDictionary *dic) {
  922 + //使用token签名时从Appserver获取token后设置token,使用Ak sk则忽略,不需要调用
  923 + [setObjectACLRequest setStrKS3Token:dic[@"Authorization"]];
  924 + KS3SetObjectACLResponse *response = [[KS3Client initialize] setObjectACL:setObjectACLRequest];
  925 + if (response.httpStatusCode == 200) {
  926 + NSLog(@"Set object acl success!");
  927 + }
  928 + else {
  929 + NSLog(@"Set object acl error: %@", response.error.description);
  930 + }
  931 + }failure:^(NSDictionary *error) {
  932 + NSLog(@"error %@",error);
  933 + }];
  934 + }
  935 + break;
  936 + case 8:
  937 + {
  938 + KS3GrantAccessControlList *acl = [[KS3GrantAccessControlList alloc] init];
  939 + acl.identifier = kObjectName;
  940 + acl.displayName = @"blues111DisplayName";
  941 + [acl setGrantControlAccess:KingSoftYun_Grant_Permission_Read];
  942 + KS3SetObjectGrantACLRequest *setObjectGrantACLRequest = [[KS3SetObjectGrantACLRequest alloc] initWithName:kBucketName withKeyName:kObjectSpecial2 grantAcl:acl];
  943 + [setObjectGrantACLRequest setCompleteRequest];
  944 +
  945 + NSArray *array = [setObjectGrantACLRequest.kSYHeader componentsSeparatedByString:@"\n"];
  946 + NSString *headers = [array firstObject];
  947 + [CNLiveUpload getAuthDicWithMd5:setObjectGrantACLRequest.contentMd5 verb:setObjectGrantACLRequest.httpMethod type:setObjectGrantACLRequest.contentType res:setObjectGrantACLRequest.kSYResource headers:headers date:setObjectGrantACLRequest.strDate success:^(NSDictionary *dic) {
  948 + //使用token签名时从Appserver获取token后设置token,使用Ak sk则忽略,不需要调用
  949 + [setObjectGrantACLRequest setStrKS3Token:dic[@"Authorization"]];
  950 + KS3SetObjectGrantACLResponse *response = [[KS3Client initialize] setObjectGrantACL:setObjectGrantACLRequest];
  951 + if (response.httpStatusCode == 200) {
  952 + NSLog(@"Set object grant acl success!");
  953 + }
  954 + else {
  955 + NSLog(@"Set object grant acl error: %@", response.error.description);
  956 + }
  957 + }failure:^(NSDictionary *error) {
  958 + NSLog(@"error %@",error);
  959 + }];
  960 + }
  961 + break;
  962 + case 9:
  963 + {
  964 + //放在点击事件里,uploadBtnClicked
  965 + }
  966 + break;
  967 + case 10:
  968 + {
  969 + [_downloader stop];
  970 + }
  971 + break;
  972 + case 11:
  973 + {
  974 + [self cancelMultipartUpload];
  975 + }
  976 + break;
  977 + case 12:
  978 + {
  979 + [self uploadWithUploadManager];
  980 + }
  981 + break;
  982 + default:
  983 + break;
  984 + }
  985 +}
  986 +
  987 +#pragma mark - 上传的回调方法
  988 +
  989 +- (void)request:(KS3Request *)request didCompleteWithResponse:(KS3Response *)response
  990 +{
  991 +
  992 + if ([request isKindOfClass:[KS3PutObjectRequest class]]) {
  993 + if (response.httpStatusCode == 200) {
  994 + NSLog(@"单块上传成功");
  995 + }else
  996 + {
  997 + NSLog(@"单块上传失败");
  998 + }
  999 +
  1000 + return;
  1001 + }else if ([request isKindOfClass:[KS3UploadPartRequest class]])
  1002 + {
  1003 + [mUserDefaults setInteger:_uploadNum forKey:keyUploadPartNum];
  1004 + [mUserDefaults synchronize];
  1005 + _uploadNum ++;
  1006 +
  1007 + if (_totalNum < _uploadNum) {
  1008 + KS3ListPartsRequest *req2 = [[KS3ListPartsRequest alloc] initWithMultipartUpload:_muilt];
  1009 + [req2 setCompleteRequest];
  1010 +
  1011 + NSArray *array = [req2.kSYHeader componentsSeparatedByString:@"\n"];
  1012 + NSString *headers = [array firstObject];
  1013 + [CNLiveUpload getAuthDicWithMd5:req2.contentMd5 verb:req2.httpMethod type:req2.contentType res:req2.kSYResource headers:headers date:req2.strDate success:^(NSDictionary *dic) {
  1014 + //使用token签名时从Appserver获取token后设置token,使用Ak sk则忽略,不需要调用
  1015 + [req2 setStrKS3Token:dic[@"Authorization"]];
  1016 +
  1017 + KS3ListPartsResponse *response2 = [[KS3Client initialize] listParts:req2];
  1018 + KS3CompleteMultipartUploadRequest *req = [[KS3CompleteMultipartUploadRequest alloc] initWithMultipartUpload:_muilt];
  1019 + NSLog(@"%@",response2.listResult.parts);
  1020 + for (KS3Part *part in response2.listResult.parts) {
  1021 + [req addPartWithPartNumber:part.partNumber withETag:part.etag];
  1022 + }
  1023 + //req参数设置完一定要调这个函数
  1024 + [req setCompleteRequest];
  1025 +
  1026 + NSArray *array = [req.kSYHeader componentsSeparatedByString:@"\n"];
  1027 + NSString *headers = [array firstObject];
  1028 + [CNLiveUpload getAuthDicWithMd5:req.contentMd5 verb:req.httpMethod type:req.contentType res:req.kSYResource headers:headers date:req.strDate success:^(NSDictionary *dic) {
  1029 + //使用token签名时从Appserver获取token后设置token,使用Ak sk则忽略,不需要调用
  1030 + [req setStrKS3Token:dic[@"Authorization"]];
  1031 +
  1032 + KS3CompleteMultipartUploadResponse *resp = [[KS3Client initialize] completeMultipartUpload:req];
  1033 + NSString *bodyStr = [[NSString alloc]initWithData:resp.body encoding:NSUTF8StringEncoding];
  1034 + if (resp.httpStatusCode != 200) {
  1035 + NSLog(@"#####complete multipart upload failed!!! code: %d#####,body = %@", resp.httpStatusCode,bodyStr);
  1036 + }else if (resp.httpStatusCode == 200)
  1037 + {
  1038 + NSLog(@"分块上传成功!!");
  1039 + [mUserDefaults setObject:nil forKey:keyUploadId];
  1040 + [mUserDefaults setInteger:0 forKey:keyUploadPartNum];
  1041 + _uploadNum = 0 ;
  1042 + [mUserDefaults synchronize];
  1043 + }
  1044 + }failure:^(NSDictionary *error) {
  1045 + NSLog(@"error %@",error);
  1046 + }];
  1047 + }failure:^(NSDictionary *error) {
  1048 + NSLog(@"error %@",error);
  1049 + }];
  1050 + }
  1051 + else {
  1052 + [self uploadWithPartNumber:_uploadNum];
  1053 + }
  1054 +
  1055 +
  1056 + }
  1057 +
  1058 +}
  1059 +
  1060 +- (void)request:(KS3Request *)request didFailWithError:(NSError *)error
  1061 +{
  1062 + NSLog(@"upload error: %@", error);
  1063 +}
  1064 +
  1065 +- (void)request:(KS3Request *)request didReceiveResponse:(NSURLResponse *)response
  1066 +{
  1067 + NSInteger statusCode = ((NSHTTPURLResponse*) response).statusCode;
  1068 + if ( (statusCode>= 200 && statusCode <300) || statusCode == 304) {
  1069 + NSLog(@"Put object success");
  1070 + }
  1071 + else {
  1072 + NSLog(@"Put object failed");
  1073 + }
  1074 +
  1075 +}
  1076 +
  1077 +- (void)request:(KS3Request *)request didReceiveData:(NSData *)data
  1078 +{
  1079 + /**
  1080 + * Never call this method, because it's upload
  1081 + *
  1082 + * @return <#return value description#>
  1083 + */
  1084 +}
  1085 +
  1086 +-(void)request:(KS3Request *)request didSendData:(long long)bytesWritten totalBytesWritten:(long long)totalBytesWritten totalBytesExpectedToWrite:(long long)totalBytesExpectedToWrite
  1087 +{
  1088 +
  1089 +
  1090 + UIProgressView *progressView = (UIProgressView *)[self.view viewWithTag:199];
  1091 + UIButton *button = (UIButton *)[self.view viewWithTag:200];
  1092 +
  1093 + if ([request isKindOfClass:[KS3PutObjectRequest class]]) {
  1094 +
  1095 + long long alreadyTotalWriten = totalBytesWritten;
  1096 + double progress = alreadyTotalWriten * 1.0 / _fileSize;
  1097 + NSLog(@"upload progress: %f", progress);
  1098 +// progressView.progress = progress;
  1099 + }else if([request isKindOfClass:[KS3UploadPartRequest class]])
  1100 + {
  1101 + if (_muilt.isCanceled ) {
  1102 + [request cancel];
  1103 + [button setTitle:@"开始" forState:UIControlStateNormal];
  1104 + button.selected = NO;
  1105 + progressView.progress = 0;
  1106 + return;
  1107 + }
  1108 +
  1109 + long long alreadyTotalWriten = (_uploadNum - 1) * _partLength + totalBytesWritten;
  1110 + double progress = alreadyTotalWriten / (float)_fileSize;
  1111 + NSLog(@"upload progress: %f", progress);
  1112 +#warning upload progress Callback
  1113 + progressView.progress = progress;
  1114 + if (progress == 1) {
  1115 + [_fileHandle closeFile];
  1116 + [button setTitle:@"完成" forState:UIControlStateNormal];
  1117 + }
  1118 + }
  1119 +
  1120 +
  1121 +
  1122 +
  1123 +}
  1124 +
  1125 +@end
... ...
KS3SDKDemo/KS3SDKDemo/PerfViewController.h 0 → 100755
  1 +//
  2 +// PerfViewController.h
  3 +// KS3SDKDemo
  4 +//
  5 +// Created by Sun Peng on 2017/6/29.
  6 +// Copyright © 2017年 Kingsoft. All rights reserved.
  7 +//
  8 +
  9 +#import <UIKit/UIKit.h>
  10 +
  11 +@interface PerfViewController : UIViewController
  12 +
  13 +@property (weak, nonatomic) IBOutlet UITextField *uploadTimes;
  14 +@property (weak, nonatomic) IBOutlet UIProgressView *totalProgress;
  15 +@property (weak, nonatomic) IBOutlet UIProgressView *currentProgress;
  16 +@property (weak, nonatomic) IBOutlet UITextView *result;
  17 +@property (weak, nonatomic) IBOutlet UIButton *startUploadButton;
  18 +
  19 +@end
... ...
KS3SDKDemo/KS3SDKDemo/PerfViewController.m 0 → 100755
  1 +//
  2 +// PerfViewController.m
  3 +// KS3SDKDemo
  4 +//
  5 +// Created by Sun Peng on 2017/6/29.
  6 +// Copyright © 2017年 Kingsoft. All rights reserved.
  7 +//
  8 +
  9 +#import "PerfViewController.h"
  10 +#import <KS3YunSDK.h>
  11 +#import "KS3Util.h"
  12 +#import "AppDelegate.h"
  13 +#import <CNLiveUploadSDK/CNLiveUpload.h>
  14 +
  15 +#define kUploadBucketName @"test-voidmain-hz-2" //上传所用的bucketName
  16 +
  17 +@interface PerfViewController ()
  18 +
  19 +@property (assign) NSInteger nextCount;
  20 +@property (assign) NSInteger successCount;
  21 +@property (assign) NSInteger totalCount;
  22 +@property (assign) NSInteger totalSize;
  23 +@property (assign) double totalTime;
  24 +
  25 +@property (nonatomic, strong) NSDate* lastStartDate;
  26 +
  27 +@property (nonatomic, strong) KS3UploadManager *uploadManager;
  28 +
  29 +@property (assign) UIBackgroundTaskIdentifier taskId;
  30 +
  31 +@end
  32 +
  33 +@implementation PerfViewController
  34 +
  35 +- (void)viewDidLoad {
  36 + [super viewDidLoad];
  37 + [self resetViews];
  38 +
  39 +// [[KS3Client initialize] setCredentials:[[KS3Credentials alloc] initWithAccessKey:strAccessKey withSecretKey:strSecretKey]];
  40 +
  41 + self.uploadManager = [KS3UploadManager sharedInstanceWithClient:[KS3Client initialize] authHandler:nil];
  42 +}
  43 +
  44 +- (void)resetViews {
  45 + self.uploadTimes.text = @"1000";
  46 +
  47 + [self resetProgressAndResult];
  48 +}
  49 +
  50 +- (void)resetProgressAndResult {
  51 + self.totalProgress.progress = 0;
  52 + self.currentProgress.progress = 0;
  53 + self.result.text = @"";
  54 +}
  55 +
  56 +- (void)resetCount {
  57 + _nextCount = 0;
  58 + _totalCount = [self.uploadTimes.text integerValue];
  59 + _successCount = 0;
  60 + _totalSize = 0;
  61 + _totalTime = 0;
  62 +}
  63 +
  64 +- (IBAction)startUpload:(id)sender {
  65 + _taskId = [[UIApplication sharedApplication] beginBackgroundTaskWithExpirationHandler:NULL];
  66 +
  67 + [self resetProgressAndResult];
  68 +
  69 + [self resetCount];
  70 + [self uploadWithUploadManager];
  71 + [self.startUploadButton setEnabled:NO];
  72 +}
  73 +
  74 +- (NSInteger) sizeAtIndex:(NSInteger)index {
  75 + NSInteger remainder = index % 10;
  76 + if (remainder < 7) {
  77 + return 200 * 1024;
  78 + } else if (remainder < 9) {
  79 + return 5 * 1024 * 1024;
  80 + } else {
  81 + return 12 * 1024 * 1024;
  82 + }
  83 +}
  84 +
  85 +- (void)uploadWithUploadManager {
  86 + _nextCount ++;
  87 + if (_nextCount > _totalCount) {
  88 + [self.startUploadButton setEnabled:YES];
  89 +
  90 + self.result.text = [NSString stringWithFormat:@"文件总大小:%ld B\n上传成功率:%.2lf\n上传总耗时:%.2lf秒", _totalSize, (_successCount * 1.0 / _totalCount), _totalTime];
  91 +
  92 + [[UIApplication sharedApplication] endBackgroundTask:_taskId];
  93 + // end
  94 + return;
  95 + }
  96 +
  97 + NSData *data = [KS3Util dataWithSize:[self sizeAtIndex:_nextCount]];
  98 + _totalSize += data.length;
  99 +
  100 + KS3AccessControlList *acl = [[KS3AccessControlList alloc] init];
  101 + [acl setContronAccess:KingSoftYun_Permission_Public_Read];
  102 +
  103 + _lastStartDate = [NSDate date];
  104 +
  105 + KS3UploadRequest *uploadRequest = [[KS3UploadRequest alloc] initWithKey:[NSString stringWithFormat:@"perf-test-%ld", _nextCount] inBucket:kUploadBucketName acl:acl grantAcl:nil];
  106 + [uploadRequest setCompleteRequest];
  107 +
  108 + NSArray *array = [uploadRequest.kSYHeader componentsSeparatedByString:@"\n"];
  109 + NSString *headers = [array firstObject];
  110 + [CNLiveUpload getAuthDicWithMd5:uploadRequest.contentMd5 verb:uploadRequest.httpMethod type:uploadRequest.contentType res:uploadRequest.kSYResource headers:headers date:uploadRequest.strDate success:^(NSDictionary *dic) {
  111 + [uploadRequest setStrKS3Token:dic[@"Authorization"]];
  112 +
  113 + [self.uploadManager putData:data
  114 + request:uploadRequest
  115 + blockSize:1 * kMB
  116 + progress:^(NSString *key, double percent) {
  117 + NSLog(@"objectKey: %@, progress %lf", key, percent);
  118 + self.currentProgress.progress = percent;
  119 + } cancelSignal:^BOOL(NSString *key) {
  120 + return false; // 修改这里进行取消
  121 + } complete:^(KS3Upload *upload, KS3Response *response) {
  122 + _successCount ++;
  123 + self.totalProgress.progress = (_nextCount * 1.0 / _totalCount);
  124 +
  125 + double deltaTime = [[NSDate date] timeIntervalSinceDate:_lastStartDate];
  126 + _totalTime += deltaTime;
  127 +
  128 + [self uploadWithUploadManager];
  129 + } error:^(KS3Upload *upload, NSError *error) {
  130 + NSLog(@"uploadId: %@, error: %@", upload.uploadId, error);
  131 +
  132 + [self uploadWithUploadManager];
  133 + }];
  134 + } failure:^(NSDictionary *error) {
  135 + NSLog(@"error %@",error);
  136 + }];
  137 +}
  138 +
  139 +- (void)touchesBegan:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event {
  140 + [self.uploadTimes endEditing:YES];
  141 +}
  142 +
  143 +@end
... ...
KS3SDKDemo/KS3SDKDemo/ServiceViewController.h 0 → 100755
  1 +//
  2 +// ServiceViewController.h
  3 +// KS3iOSSDKDemo
  4 +//
  5 +// Created by Blues on 12/16/14.
  6 +// Copyright (c) 2014 Blues. All rights reserved.
  7 +//
  8 +
  9 +#import <UIKit/UIKit.h>
  10 +
  11 +@interface ServiceViewController : UIViewController
  12 +
  13 +@end
... ...
KS3SDKDemo/KS3SDKDemo/ServiceViewController.m 0 → 100755
  1 +//
  2 +// ServiceViewController.m
  3 +// KS3iOSSDKDemo
  4 +//
  5 +// Created by Blues on 12/16/14.
  6 +// Copyright (c) 2014 Blues. All rights reserved.
  7 +//
  8 +
  9 +#import "ServiceViewController.h"
  10 +
  11 +@interface ServiceViewController ()
  12 +
  13 +@property (nonatomic, strong) NSArray *arrItems;
  14 +
  15 +@end
  16 +
  17 +@implementation ServiceViewController
  18 +
  19 +- (void)viewDidLoad
  20 +{
  21 + [super viewDidLoad];
  22 + self.navigationItem.title = @"Service";
  23 + _arrItems = [NSArray arrayWithObjects:@"List Buckets", nil];
  24 +}
  25 +
  26 +#pragma mark - UITableView datasource
  27 +
  28 +- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
  29 +{
  30 + return _arrItems.count;
  31 +}
  32 +
  33 +- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
  34 +{
  35 + NSString *strIdentifier = @"service identifier";
  36 + UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:strIdentifier];
  37 + if (nil == cell) {
  38 + cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:strIdentifier];
  39 + }
  40 + cell.textLabel.text = _arrItems[indexPath.row];
  41 + return cell;
  42 +}
  43 +
  44 +#pragma mark - UITableView delegate
  45 +
  46 +- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
  47 +{
  48 + NSString *strIdentifier = @"";
  49 + switch (indexPath.row) {
  50 + case 0:
  51 + strIdentifier = @"List Bucket Identifier";
  52 + break;
  53 + default:
  54 + break;
  55 + }
  56 + [self performSegueWithIdentifier:strIdentifier sender:nil];
  57 +}
  58 +
  59 +@end
... ...
KS3SDKDemo/KS3SDKDemo/VideoViewController.h 0 → 100755
  1 +//
  2 +// VideoViewController.h
  3 +// KS3SDKDemo-Token
  4 +//
  5 +// Created by Marlon Chan on 16/6/27.
  6 +// Copyright © 2016年 Jack Wong. All rights reserved.
  7 +//
  8 +
  9 +#import <UIKit/UIKit.h>
  10 +
  11 +@interface VideoViewController : UIViewController
  12 +
  13 +@end
... ...
KS3SDKDemo/KS3SDKDemo/VideoViewController.m 0 → 100755
  1 +//
  2 +// VideoViewController.m
  3 +// KS3SDKDemo-Token
  4 +//
  5 +// Created by Marlon Chan on 16/6/27.
  6 +// Copyright © 2016年 Jack Wong. All rights reserved.
  7 +//
  8 +
  9 +#define mUserDefaults [NSUserDefaults standardUserDefaults]
  10 +//上传
  11 +#define kUploadBucketName @"gzz-beijing" //上传所用的bucketName
  12 +#define kUploadObjectKey @"wz/7.6M.mov" //上传时用到的bucket里文件的路径,此为在wz目录下7.6M.mov
  13 +
  14 +
  15 +#import "VideoViewController.h"
  16 +#import <KS3YunSDK.h>
  17 +#import "KS3Util.h"
  18 +#import <CNLiveUploadSDK/CNLiveUpload.h>
  19 +//#import "AppDelegate.h"
  20 +
  21 +@interface VideoViewController () <KingSoftServiceRequestDelegate>
  22 +
  23 +@property (nonatomic, strong) NSArray *arrItems;
  24 +@property (assign, nonatomic) long long fileSize;
  25 +
  26 +@end
  27 +
  28 +@implementation VideoViewController
  29 +
  30 +- (void)viewDidLoad {
  31 + [super viewDidLoad];
  32 + self.view.backgroundColor = [UIColor whiteColor];
  33 + // Do any additional setup after loading the view.
  34 + self.navigationItem.title = @"Video";
  35 + _arrItems = [NSArray arrayWithObjects:@"视频转码(utp)", @"视频截图(adp)", nil];
  36 +
  37 +}
  38 +
  39 +
  40 +- (void)beginUploadTriggerProcessing
  41 +{
  42 + KS3AccessControlList *ControlList = [[KS3AccessControlList alloc] init];
  43 + [ControlList setContronAccess:KingSoftYun_Permission_Public_Read_Write];
  44 + KS3PutObjectRequest *putObjRequest = [[KS3PutObjectRequest alloc] initWithName:kUploadBucketName withAcl:ControlList grantAcl:nil];
  45 + NSString *fileName = [[NSBundle mainBundle] pathForResource:@"7.6M" ofType:@"mov"];
  46 + putObjRequest.data = [NSData dataWithContentsOfFile:fileName options:NSDataReadingMappedIfSafe error:nil];
  47 + _fileSize = putObjRequest.data.length;
  48 +
  49 + putObjRequest.delegate = self;
  50 + putObjRequest.filename = kUploadObjectKey;
  51 + putObjRequest.contentMd5 = [KS3SDKUtil base64md5FromData:putObjRequest.data];
  52 +
  53 + //视频转码命令
  54 + NSString* utpCommand =[NSString stringWithFormat:@"tag=avop&f=mp4|tag=saveas&bucket=%@&object=%@",kUploadBucketName, [[@"wz/result.mp4" dataUsingEncoding:NSUTF8StringEncoding] base64Encoding]];
  55 + [putObjRequest.urlRequest setValue:utpCommand forHTTPHeaderField:@"kss-async-process"];
  56 + [putObjRequest.urlRequest setValue:@"http://10.4.2.38:19090/" forHTTPHeaderField:@"kss-notifyurl"];
  57 +
  58 + [putObjRequest setCompleteRequest];
  59 +
  60 + NSArray *array = [putObjRequest.kSYHeader componentsSeparatedByString:@"\n"];
  61 + NSString *headers = [array firstObject];
  62 +
  63 + //生产环境应从Appserver获取token后设置token,此处使用Ak sk计算token模拟
  64 + [CNLiveUpload getAuthDicWithMd5:putObjRequest.contentMd5 verb:putObjRequest.httpMethod type:putObjRequest.contentType res:putObjRequest.kSYResource headers:headers date:putObjRequest.strDate success:^(NSDictionary *dic) {
  65 + [putObjRequest setStrKS3Token:dic[@"Authorization"]];
  66 + KS3PutObjectResponse *response = [[KS3Client initialize] putObject:putObjRequest];
  67 +
  68 + //putObjRequest若没设置代理,则是同步的下方判断,
  69 + //putObjRequest若设置了代理,则走上传代理回调,
  70 + if (putObjRequest.delegate == nil) {
  71 + NSLog(@"%@",[[NSString alloc] initWithData:response.body encoding:NSUTF8StringEncoding]);
  72 + if (response.httpStatusCode == 200) {
  73 + NSLog(@"Put object success");
  74 + }
  75 + else {
  76 + NSLog(@"Put object failed");
  77 + }
  78 + }
  79 + } failure:^(NSDictionary *error) {
  80 + NSLog(@"error: %@",error);
  81 + }];
  82 +}
  83 +
  84 +- (void)beginAsynchronousDataProcessing
  85 +{
  86 +
  87 + KS3AccessControlList *ControlList = [[KS3AccessControlList alloc] init];
  88 + [ControlList setContronAccess:KingSoftYun_Permission_Public_Read_Write];
  89 +
  90 + KS3PutObjectRequest *putObjRequest = [[KS3PutObjectRequest alloc] initWithName:kUploadBucketName withAcl:ControlList grantAcl:nil];
  91 + putObjRequest.delegate = self;
  92 + putObjRequest.filename = [kUploadObjectKey stringByAppendingString:@"?adp"];
  93 +
  94 + //视频截图命令
  95 + NSString* adpCommand =[NSString stringWithFormat:@"tag=avscrnshot&ss=1&res=640x360&&rotate=90|tag=saveas&bucket=%@&object=%@",kUploadBucketName, [[@"wz/screenshot_iossdk.png" dataUsingEncoding:NSUTF8StringEncoding] base64Encoding]];
  96 + [putObjRequest.urlRequest setValue:adpCommand forHTTPHeaderField:@"kss-async-process"];
  97 + [putObjRequest.urlRequest setValue:@"http://10.4.2.38:19090/" forHTTPHeaderField:@"kss-notifyurl"];
  98 +
  99 + [putObjRequest setCompleteRequest];
  100 + //putObjRequest.kSYResource = [NSString stringWithFormat:@"/%@/%@?%@",kUploadBucketName,kUploadObjectKey, @"adp"];
  101 +
  102 + NSArray *array = [putObjRequest.kSYHeader componentsSeparatedByString:@"\n"];
  103 + NSString *headers = [array firstObject];
  104 + [CNLiveUpload getAuthDicWithMd5:putObjRequest.contentMd5 verb:putObjRequest.httpMethod type:putObjRequest.contentType res:putObjRequest.kSYResource headers:headers date:putObjRequest.strDate success:^(NSDictionary *dic) {
  105 + //生产环境应从Appserver获取token后设置token,此处使用Ak sk计算token模拟
  106 + [putObjRequest setStrKS3Token:dic[@"Authorization"]];
  107 + KS3PutObjectResponse *response = [[KS3Client initialize] putObject:putObjRequest];
  108 +
  109 + //putObjRequest若没设置代理,则是同步的下方判断,
  110 + //putObjRequest若设置了代理,则走上传代理回调,
  111 + if (putObjRequest.delegate == nil) {
  112 + NSLog(@"%@",[[NSString alloc] initWithData:response.body encoding:NSUTF8StringEncoding]);
  113 + if (response.httpStatusCode == 200) {
  114 + NSLog(@"Put object success");
  115 + }
  116 + else {
  117 + NSLog(@"Put object failed");
  118 + }
  119 + }
  120 + } failure:^(NSDictionary *error) {
  121 + NSLog(@"error %@",error);
  122 + }];
  123 +}
  124 +
  125 +#pragma mark - UITableView delegate
  126 +- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
  127 +{
  128 + switch (indexPath.row) {
  129 + case 0: //utp
  130 + {
  131 + [self beginUploadTriggerProcessing];
  132 +
  133 + }
  134 + break;
  135 + case 1: //adp
  136 + {
  137 + [self beginAsynchronousDataProcessing];
  138 + }
  139 + break;
  140 + default:
  141 + break;
  142 + }
  143 +}
  144 +
  145 +
  146 +#pragma mark - UITableView datasource
  147 +- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
  148 +{
  149 + return _arrItems.count;
  150 +}
  151 +
  152 +- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
  153 +{
  154 + NSString *strIdentifier = @"Video identifier";
  155 + UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:strIdentifier];
  156 + if (nil == cell) {
  157 + cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:strIdentifier];
  158 + }
  159 + cell.textLabel.text = _arrItems[indexPath.row];
  160 + return cell;
  161 +}
  162 +
  163 +#pragma mark - 上传的回调方法
  164 +
  165 +- (void)request:(KS3Request *)request didCompleteWithResponse:(KS3Response *)response
  166 +{
  167 +
  168 + if ([request isKindOfClass:[KS3PutObjectRequest class]]) {
  169 + if (response.httpStatusCode == 200) {
  170 + NSLog(@"请求成功");
  171 + }else
  172 + {
  173 + NSLog(@"请求失败");
  174 + }
  175 +
  176 + return;
  177 + }
  178 +}
  179 +
  180 +- (void)request:(KS3Request *)request didFailWithError:(NSError *)error
  181 +{
  182 + NSLog(@"upload error: %@", error);
  183 +}
  184 +
  185 +- (void)request:(KS3Request *)request didReceiveResponse:(NSURLResponse *)response
  186 +{
  187 + NSInteger statusCode = ((NSHTTPURLResponse*) response).statusCode;
  188 +
  189 + //for debug
  190 + NSLog(@"response: %@", response);
  191 +
  192 + if ( (statusCode>= 200 && statusCode <300) || statusCode == 304) {
  193 + NSLog(@"Put object success");
  194 + }
  195 + else {
  196 + NSLog(@"Put object failed");
  197 + }
  198 +
  199 +}
  200 +
  201 +- (void)request:(KS3Request *)request didReceiveData:(NSData *)data
  202 +{
  203 + /**
  204 + * Never call this method, because it's upload
  205 + *
  206 + * @return <#return value description#>
  207 + */
  208 +}
  209 +
  210 +-(void)request:(KS3Request *)request didSendData:(long long)bytesWritten totalBytesWritten:(long long)totalBytesWritten totalBytesExpectedToWrite:(long long)totalBytesExpectedToWrite
  211 +{
  212 +
  213 +
  214 + UIProgressView *progressView = (UIProgressView *)[self.view viewWithTag:199];
  215 + UIButton *button = (UIButton *)[self.view viewWithTag:200];
  216 +
  217 + if ([request isKindOfClass:[KS3PutObjectRequest class]]) {
  218 +
  219 + long long alreadyTotalWriten = totalBytesWritten;
  220 + double progress = alreadyTotalWriten * 1.0 / _fileSize;
  221 + NSLog(@"upload progress: %f", progress);
  222 + }
  223 +
  224 +}
  225 +
  226 +
  227 +
  228 +- (void)didReceiveMemoryWarning {
  229 + [super didReceiveMemoryWarning];
  230 + // Dispose of any resources that can be recreated.
  231 +}
  232 +
  233 +/*
  234 +#pragma mark - Navigation
  235 +
  236 +// In a storyboard-based application, you will often want to do a little preparation before navigation
  237 +- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
  238 + // Get the new view controller using [segue destinationViewController].
  239 + // Pass the selected object to the new view controller.
  240 +}
  241 +*/
  242 +
  243 +@end
... ...
KS3SDKDemo/KS3SDKDemo/ViewController.h 0 → 100755
  1 +//
  2 +// ViewController.h
  3 +// KS3SDKDemo-Token
  4 +//
  5 +// Created by JackWong on 15/4/28.
  6 +// Copyright (c) 2015年 Jack Wong. All rights reserved.
  7 +//
  8 +
  9 +#import <UIKit/UIKit.h>
  10 +
  11 +@interface ViewController : UIViewController
  12 +
  13 +
  14 +@end
  15 +
... ...
KS3SDKDemo/KS3SDKDemo/ViewController.m 0 → 100755
  1 +//
  2 +// ViewController.m
  3 +// KS3SDKDemo-Token
  4 +//
  5 +// Created by JackWong on 15/4/28.
  6 +// Copyright (c) 2015年 Jack Wong. All rights reserved.
  7 +//
  8 +
  9 +#import "ViewController.h"
  10 +#import <KS3YunSDK.h>
  11 +#import "VideoViewController.h"
  12 +
  13 +@interface ViewController ()
  14 +
  15 +@property (nonatomic, strong) NSArray *arrItems;
  16 +
  17 +@end
  18 +
  19 +@implementation ViewController
  20 +
  21 +- (void)viewDidLoad {
  22 + [super viewDidLoad];
  23 +
  24 + self.navigationItem.title = @"KS3 SDK for iOS Demo";
  25 + self.arrItems = [NSArray arrayWithObjects:@"Service", @"Bucket", @"Object", @"Perf Test",nil];
  26 +}
  27 +
  28 +- (void)didReceiveMemoryWarning {
  29 + [super didReceiveMemoryWarning];
  30 +}
  31 +
  32 +#pragma mark - UITableView datasource
  33 +
  34 +- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
  35 +{
  36 + return _arrItems.count;
  37 +}
  38 +
  39 +- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
  40 +{
  41 + NSString *strIdentifier = @"item identifier";
  42 + UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:strIdentifier];
  43 + if (nil == cell) {
  44 + cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:strIdentifier];
  45 + }
  46 + cell.textLabel.text = _arrItems[indexPath.row];
  47 + return cell;
  48 +}
  49 +
  50 +#pragma mark - UITableView delegate
  51 +
  52 +- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
  53 +{
  54 + NSString *strIdentifier = @"";
  55 + switch (indexPath.row) {
  56 + case 0:
  57 + strIdentifier = @"Service Identifier";
  58 + break;
  59 + case 1:
  60 + strIdentifier = @"Bucket Identifier";
  61 + break;
  62 + case 2:
  63 + strIdentifier = @"Object Identifier";
  64 + break;
  65 + case 3:
  66 + strIdentifier = @"Perf Identifier";
  67 + break;
  68 + default:
  69 + break;
  70 + }
  71 + [self performSegueWithIdentifier:strIdentifier sender:nil];
  72 +}
  73 +
  74 +
  75 +@end
... ...
KS3SDKDemo/KS3SDKDemo/main.m 0 → 100755
  1 +//
  2 +// main.m
  3 +// KS3SDKDemo-Token
  4 +//
  5 +// Created by JackWong on 15/4/28.
  6 +// Copyright (c) 2015年 Jack Wong. All rights reserved.
  7 +//
  8 +
  9 +#import <UIKit/UIKit.h>
  10 +#import "AppDelegate.h"
  11 +
  12 +int main(int argc, char * argv[]) {
  13 + @autoreleasepool {
  14 + return UIApplicationMain(argc, argv, nil, NSStringFromClass([AppDelegate class]));
  15 + }
  16 +}
... ...
KS3SDKDemo/Podfile 0 → 100755
  1 +source 'https://github.com/CocoaPods/Specs.git'
  2 +
  3 +target "KS3SDKDemo" do
  4 + platform :ios, "7.0"
  5 + pod 'Ks3SDK',:path => '../'
  6 +end
... ...