Passed
Push — v6 ( 3606bd...432c9e )
by 光春
03:12
created
src/service/ksyun/bin/exceptions/Exceptions.php 1 patch
Indentation   +27 added lines, -27 removed lines patch added patch discarded remove patch
@@ -3,32 +3,32 @@
 block discarded – undo
3 3
 	
4 4
 }
5 5
 class Ks3ServiceException extends Ks3ClientException{
6
-	private $requestId;
7
-	private $errorCode;
8
-	private $errorMessage;
9
-	private $resource;
10
-	private $statusCode;
11
-	public function __set($property_name, $value){
12
-		$this->$property_name=$value;
13
-	}
14
-	public function __get($property_name){
15
-		if(isset($this->$property_name))
16
-		{
17
-			return($this->$property_name);
18
-		}else
19
-		{
20
-			return(NULL);
21
-		}
22
-	}
23
-	public function __toString()
24
-  	{
25
-      		$message = get_class($this) . ': '
26
-      			."(errorCode:".$this->errorCode.";"
27
-      			."errorMessage:".$this->errorMessage.";"
28
-      			."resource:".$this->resource.";"
29
-      			."requestId:".$this->requestId.";"
30
-      			."statusCode:".$this->statusCode.")";
31
-		return $message;
32
-      	}
6
+    private $requestId;
7
+    private $errorCode;
8
+    private $errorMessage;
9
+    private $resource;
10
+    private $statusCode;
11
+    public function __set($property_name, $value){
12
+        $this->$property_name=$value;
13
+    }
14
+    public function __get($property_name){
15
+        if(isset($this->$property_name))
16
+        {
17
+            return($this->$property_name);
18
+        }else
19
+        {
20
+            return(NULL);
21
+        }
22
+    }
23
+    public function __toString()
24
+        {
25
+                $message = get_class($this) . ': '
26
+                    ."(errorCode:".$this->errorCode.";"
27
+                    ."errorMessage:".$this->errorMessage.";"
28
+                    ."resource:".$this->resource.";"
29
+                    ."requestId:".$this->requestId.";"
30
+                    ."statusCode:".$this->statusCode.")";
31
+        return $message;
32
+            }
33 33
 }
34 34
 ?>
35 35
\ No newline at end of file
Please login to merge, or discard this patch.
src/service/ksyun/bin/core/Headers.php 1 patch
Indentation   +23 added lines, -23 removed lines patch added patch discarded remove patch
@@ -1,29 +1,29 @@
 block discarded – undo
1 1
 <?php
2 2
 class Headers{
3
-	static $Date = "Date";
4
-	static $Authorization = "Authorization";
5
-	static $ContentMd5 = "Content-MD5";
6
-	static $ContentType = "Content-Type";
7
-	static $ContentLength="Content-Length";
8
-	static $Acl = "x-kss-acl";
9
-	static $CopySource = "x-kss-copy-source";
10
-	static $ETag = "ETag";
11
-	static $TaskID = "TaskID";
12
-	static $Range = "Range";
13
-	static $AsynchronousProcessingList = "kss-async-process";
14
-	static $NotifyURL = "kss-notifyurl";
15
-	static $XKssCallbackUrl = "x-kss-callbackurl";
16
-	static $XKssCallbackBody = "x-kss-callbackbody";
17
-	static $UserAgent = "User-Agent";
18
-	static $SSEAlgm = "x-kss-server-side-encryption";
19
-	static $SSEKMSId = "x-kss-server-side-encryption-kss-kms-key-id";
20
-	static $SSECAlgm = "x-kss-server-side-encryption-customer-algorithm";
21
-	static $SSECKey = "x-kss-server-side-encryption-customer-key";
22
-	static $SSECMD5 = "x-kss-server-side-encryption-customer-key-MD5";
3
+    static $Date = "Date";
4
+    static $Authorization = "Authorization";
5
+    static $ContentMd5 = "Content-MD5";
6
+    static $ContentType = "Content-Type";
7
+    static $ContentLength="Content-Length";
8
+    static $Acl = "x-kss-acl";
9
+    static $CopySource = "x-kss-copy-source";
10
+    static $ETag = "ETag";
11
+    static $TaskID = "TaskID";
12
+    static $Range = "Range";
13
+    static $AsynchronousProcessingList = "kss-async-process";
14
+    static $NotifyURL = "kss-notifyurl";
15
+    static $XKssCallbackUrl = "x-kss-callbackurl";
16
+    static $XKssCallbackBody = "x-kss-callbackbody";
17
+    static $UserAgent = "User-Agent";
18
+    static $SSEAlgm = "x-kss-server-side-encryption";
19
+    static $SSEKMSId = "x-kss-server-side-encryption-kss-kms-key-id";
20
+    static $SSECAlgm = "x-kss-server-side-encryption-customer-algorithm";
21
+    static $SSECKey = "x-kss-server-side-encryption-customer-key";
22
+    static $SSECMD5 = "x-kss-server-side-encryption-customer-key-MD5";
23 23
 
24
-	static $SSECSourceAlgm = "x-kss-copy-source-server-side-encryption-customer-algorithm";
25
-	static $SSECSourceKey = "x-kss-copy-source-server-side-encryption-customer-key";
26
-	static $SSECSourceMD5 = "x-kss-copy-source-server-side-encryption-customer-key-MD5";
24
+    static $SSECSourceAlgm = "x-kss-copy-source-server-side-encryption-customer-algorithm";
25
+    static $SSECSourceKey = "x-kss-copy-source-server-side-encryption-customer-key";
26
+    static $SSECSourceMD5 = "x-kss-copy-source-server-side-encryption-customer-key-MD5";
27 27
 
28 28
 }
29 29
 ?>
30 30
\ No newline at end of file
Please login to merge, or discard this patch.
src/service/ksyun/bin/core/Logger.php 1 patch
Indentation   +37 added lines, -37 removed lines patch added patch discarded remove patch
@@ -1,46 +1,46 @@
 block discarded – undo
1 1
 <?php
2 2
 require_once KS3_API_PATH.DIRECTORY_SEPARATOR."exceptions".DIRECTORY_SEPARATOR."Exceptions.php";
3 3
 class Logger{
4
-	function info($msg){
5
-		$this->log("INFO",$msg);
6
-	}
7
-	function error($msg){
8
-		$this->log("ERROR",$msg);
9
-	}
10
-	function warn($msg){
11
-		$this->log("WARN",$msg);
12
-	}
13
-	function debug($msg){
14
-		$this->log("DEBUG",$msg);
15
-	}
16
-	private function log($level,$msg){
17
-		$date = gmdate('D, d M Y H:i:s \G\M\T');
18
-		$log = $date." ".$level."\r\n".$msg."\r\n";
19
-		if(defined('KS3_API_LOG_PATH') ){
20
-			$log_path = KS3_API_LOG_PATH;
21
-			if(empty($log_path)){
22
-				$log_path = KS3_API_PATH.DIRECTORY_SEPARATOR.'log'.DIRECTORY_SEPARATOR;
23
-			}
24
-		}else{
25
-			$log_path = KS3_API_PATH.DIRECTORY_SEPARATOR.'log'.DIRECTORY_SEPARATOR;
26
-		}
4
+    function info($msg){
5
+        $this->log("INFO",$msg);
6
+    }
7
+    function error($msg){
8
+        $this->log("ERROR",$msg);
9
+    }
10
+    function warn($msg){
11
+        $this->log("WARN",$msg);
12
+    }
13
+    function debug($msg){
14
+        $this->log("DEBUG",$msg);
15
+    }
16
+    private function log($level,$msg){
17
+        $date = gmdate('D, d M Y H:i:s \G\M\T');
18
+        $log = $date." ".$level."\r\n".$msg."\r\n";
19
+        if(defined('KS3_API_LOG_PATH') ){
20
+            $log_path = KS3_API_LOG_PATH;
21
+            if(empty($log_path)){
22
+                $log_path = KS3_API_PATH.DIRECTORY_SEPARATOR.'log'.DIRECTORY_SEPARATOR;
23
+            }
24
+        }else{
25
+            $log_path = KS3_API_PATH.DIRECTORY_SEPARATOR.'log'.DIRECTORY_SEPARATOR;
26
+        }
27 27
 		
28
-		//检测日志目录是否存在
29
-		if(!file_exists($log_path)){
30
-			mkdir($log_path);
31
-		}
28
+        //检测日志目录是否存在
29
+        if(!file_exists($log_path)){
30
+            mkdir($log_path);
31
+        }
32 32
 
33
-		$log_name = $log_path.'ks3_php_sdk_'.date('Y-m-d').'.log';
33
+        $log_name = $log_path.'ks3_php_sdk_'.date('Y-m-d').'.log';
34 34
 
35
-		if(KS3_API_DISPLAY_LOG){
36
-			echo $log;
37
-		}
35
+        if(KS3_API_DISPLAY_LOG){
36
+            echo $log;
37
+        }
38 38
 		
39
-		if(KS3_API_LOG){
40
-			if(!error_log($log,3,$log_name)){
41
-				throw new Ks3ClientException("write to log file error");
42
-			}
43
-		}
44
-	}
39
+        if(KS3_API_LOG){
40
+            if(!error_log($log,3,$log_name)){
41
+                throw new Ks3ClientException("write to log file error");
42
+            }
43
+        }
44
+    }
45 45
 }
46 46
 ?>
47 47
\ No newline at end of file
Please login to merge, or discard this patch.
src/service/ksyun/bin/core/Builders.php 1 patch
Indentation   +84 added lines, -84 removed lines patch added patch discarded remove patch
@@ -3,100 +3,100 @@
 block discarded – undo
3 3
 require_once KS3_API_PATH.DIRECTORY_SEPARATOR."config".DIRECTORY_SEPARATOR."Consts.php";
4 4
 
5 5
 class LocationBuilder{
6
-	function build($args){
7
-		if(isset($args["Location"])){
8
-			$location = $args["Location"];
9
-			$xml = new SimpleXmlElement('<CreateBucketConfiguration xmlns="http://s3.amazonaws.com/doc/2006-03-01/"></CreateBucketConfiguration>');
10
-			$xml->addChild("LocationConstraint",$args["Location"]);
11
-			return $xml->asXml();
12
-		}
13
-	}
6
+    function build($args){
7
+        if(isset($args["Location"])){
8
+            $location = $args["Location"];
9
+            $xml = new SimpleXmlElement('<CreateBucketConfiguration xmlns="http://s3.amazonaws.com/doc/2006-03-01/"></CreateBucketConfiguration>');
10
+            $xml->addChild("LocationConstraint",$args["Location"]);
11
+            return $xml->asXml();
12
+        }
13
+    }
14 14
 }
15 15
 class CORSBuilder{
16
-	function build($args){
17
-		if(isset($args["CORS"])){
18
-			$cors = $args["CORS"];
19
-			$xml = new SimpleXmlElement('<CORSConfiguration xmlns="http://s3.amazonaws.com/doc/2006-03-01/"></CORSConfiguration>');
20
-			if(is_array($cors)){
21
-				foreach ($cors as $key => $rule) {
22
-					$ruleXml = $xml->addChild("CORSRule");
23
-					if(is_array($rule)){
24
-						foreach ($rule as $key => $value) {
25
-							if(in_array($key,Consts::$CORSElements)){
26
-								if(is_array($value)){
27
-									foreach ($value as  $ele) {
28
-										$ruleXml->addChild($key,$ele);
29
-									}
30
-								}else{
31
-									$ruleXml->addChild($key,$value);
32
-								}
16
+    function build($args){
17
+        if(isset($args["CORS"])){
18
+            $cors = $args["CORS"];
19
+            $xml = new SimpleXmlElement('<CORSConfiguration xmlns="http://s3.amazonaws.com/doc/2006-03-01/"></CORSConfiguration>');
20
+            if(is_array($cors)){
21
+                foreach ($cors as $key => $rule) {
22
+                    $ruleXml = $xml->addChild("CORSRule");
23
+                    if(is_array($rule)){
24
+                        foreach ($rule as $key => $value) {
25
+                            if(in_array($key,Consts::$CORSElements)){
26
+                                if(is_array($value)){
27
+                                    foreach ($value as  $ele) {
28
+                                        $ruleXml->addChild($key,$ele);
29
+                                    }
30
+                                }else{
31
+                                    $ruleXml->addChild($key,$value);
32
+                                }
33 33
 								
34
-							}
35
-						}
36
-					}
37
-				}
38
-			}
39
-			return $xml->asXml();
40
-		}
41
-	}
34
+                            }
35
+                        }
36
+                    }
37
+                }
38
+            }
39
+            return $xml->asXml();
40
+        }
41
+    }
42 42
 }
43 43
 class BucketLoggingBuilder{
44
-	function build($args){
45
-		if(isset($args["BucketLogging"])){
46
-			$logging = $args["BucketLogging"];
47
-			$xml = new SimpleXmlElement('<BucketLoggingStatus xmlns="http://s3.amazonaws.com/doc/2006-03-01/" />');
48
-			if(is_array($logging)){
44
+    function build($args){
45
+        if(isset($args["BucketLogging"])){
46
+            $logging = $args["BucketLogging"];
47
+            $xml = new SimpleXmlElement('<BucketLoggingStatus xmlns="http://s3.amazonaws.com/doc/2006-03-01/" />');
48
+            if(is_array($logging)){
49 49
 
50
-				if(!isset($logging["Enable"]))
51
-					throw new Ks3ClientException("bucket logging must provide Enable argument");
50
+                if(!isset($logging["Enable"]))
51
+                    throw new Ks3ClientException("bucket logging must provide Enable argument");
52 52
 				
53
-				if($logging["Enable"]){
54
-					if(!isset($logging["TargetBucket"]))
55
-						throw new Ks3ClientException("bucket logging must provide TargetBucket argument");
56
-					$loggingConfig = $xml->addChild("LoggingEnabled");
57
-					foreach ($logging as $key => $value) {
58
-						if(in_array($key,Consts::$BucketLoggingElements)){
59
-							$loggingConfig->addChild($key,$value);
60
-						}
61
-					}
62
-				}
63
-			}
64
-			return $xml->asXml();
65
-		}
66
-	}
53
+                if($logging["Enable"]){
54
+                    if(!isset($logging["TargetBucket"]))
55
+                        throw new Ks3ClientException("bucket logging must provide TargetBucket argument");
56
+                    $loggingConfig = $xml->addChild("LoggingEnabled");
57
+                    foreach ($logging as $key => $value) {
58
+                        if(in_array($key,Consts::$BucketLoggingElements)){
59
+                            $loggingConfig->addChild($key,$value);
60
+                        }
61
+                    }
62
+                }
63
+            }
64
+            return $xml->asXml();
65
+        }
66
+    }
67 67
 }
68 68
 class DeleteObjectsBuilder{
69
-	function build($args){
70
-		if(isset($args["DeleteKeys"])){
71
-			$keys = $args["DeleteKeys"];
72
-			$xml = new SimpleXmlElement('<Delete></Delete>');
73
-			if(is_array($keys)){
74
-				foreach ($keys as $key => $value) {
75
-					$object = $xml->addChild("Object");
76
-					$object->addChild("Key",$value);
77
-				}
78
-			}
79
-			return $xml->asXml();
80
-		}
81
-	}
69
+    function build($args){
70
+        if(isset($args["DeleteKeys"])){
71
+            $keys = $args["DeleteKeys"];
72
+            $xml = new SimpleXmlElement('<Delete></Delete>');
73
+            if(is_array($keys)){
74
+                foreach ($keys as $key => $value) {
75
+                    $object = $xml->addChild("Object");
76
+                    $object->addChild("Key",$value);
77
+                }
78
+            }
79
+            return $xml->asXml();
80
+        }
81
+    }
82 82
 }
83 83
 class CompleteMultipartUploadBuilder{
84
-	function build($args){
85
-		if(isset($args["Parts"])){
86
-			$parts = $args["Parts"];
87
-			$xml = new SimpleXmlElement('<CompleteMultipartUpload></CompleteMultipartUpload>');
88
-			if(is_array($parts)){
89
-				foreach ($parts as $part) {
90
-					$partXml = $xml->addChild("Part");
91
-					foreach ($part as $key => $value) {
92
-						if(in_array($key,Consts::$PartsElement)){
93
-							$partXml->addChild($key,$value);
94
-						}
95
-					}
96
-				}
97
-			}
98
-			return $xml->asXml();
99
-		}
100
-	}
84
+    function build($args){
85
+        if(isset($args["Parts"])){
86
+            $parts = $args["Parts"];
87
+            $xml = new SimpleXmlElement('<CompleteMultipartUpload></CompleteMultipartUpload>');
88
+            if(is_array($parts)){
89
+                foreach ($parts as $part) {
90
+                    $partXml = $xml->addChild("Part");
91
+                    foreach ($part as $key => $value) {
92
+                        if(in_array($key,Consts::$PartsElement)){
93
+                            $partXml->addChild($key,$value);
94
+                        }
95
+                    }
96
+                }
97
+            }
98
+            return $xml->asXml();
99
+        }
100
+    }
101 101
 }
102 102
 ?>
103 103
\ No newline at end of file
Please login to merge, or discard this patch.
src/service/ksyun/bin/core/Signers.php 1 patch
Indentation   +473 added lines, -473 removed lines patch added patch discarded remove patch
@@ -6,536 +6,536 @@
 block discarded – undo
6 6
 require_once KS3_API_PATH.DIRECTORY_SEPARATOR."exceptions".DIRECTORY_SEPARATOR."Exceptions.php";
7 7
 
8 8
 interface Signer{
9
-	public function sign( Ks3Request $request,$args=array());
9
+    public function sign( Ks3Request $request,$args=array());
10 10
 }
11 11
 class DefaultUserAgentSigner implements Signer{
12
-	public function sign(Ks3Request $request,$args=array()){
13
-		$request->addHeader(Headers::$UserAgent,Consts::$UserAgent);
14
-	}
12
+    public function sign(Ks3Request $request,$args=array()){
13
+        $request->addHeader(Headers::$UserAgent,Consts::$UserAgent);
14
+    }
15 15
 }
16 16
 class DefaultContentTypeSigner implements Signer{
17
-	public function sign(Ks3Request $request,$args=array()){
18
-		$contentType = $request->getHeader(Headers::$ContentType);
19
-		if(empty($contentType)){
20
-			$request->addHeader(Headers::$ContentType,"application/xml");
21
-		}
22
-	}
17
+    public function sign(Ks3Request $request,$args=array()){
18
+        $contentType = $request->getHeader(Headers::$ContentType);
19
+        if(empty($contentType)){
20
+            $request->addHeader(Headers::$ContentType,"application/xml");
21
+        }
22
+    }
23 23
 }
24 24
 class StreamContentTypeSigner implements Signer{
25
-	public function sign(Ks3Request $request,$args=array()){
26
-		$contentType = $request->getHeader(Headers::$ContentType);
27
-		if(empty($contentType)){
28
-			$request->addHeader(Headers::$ContentType,"application/ocet-stream");
29
-		}
30
-	}
25
+    public function sign(Ks3Request $request,$args=array()){
26
+        $contentType = $request->getHeader(Headers::$ContentType);
27
+        if(empty($contentType)){
28
+            $request->addHeader(Headers::$ContentType,"application/ocet-stream");
29
+        }
30
+    }
31 31
 }
32 32
 class SuffixContentTypeSigner implements Signer{
33
-	public function sign(Ks3Request $request,$args=array()){
34
-		$key = $request->key;
35
-		$objArr = explode('/', $key);
36
-		$basename = array_pop($objArr);
37
-		$extension = explode ( '.', $basename );
38
-		$extension = array_pop ( $extension );
39
-		$content_type = Utils::get_mimetype(strtolower($extension));
40
-		$request->addHeader(Headers::$ContentType,$content_type);
41
-	}
33
+    public function sign(Ks3Request $request,$args=array()){
34
+        $key = $request->key;
35
+        $objArr = explode('/', $key);
36
+        $basename = array_pop($objArr);
37
+        $extension = explode ( '.', $basename );
38
+        $extension = array_pop ( $extension );
39
+        $content_type = Utils::get_mimetype(strtolower($extension));
40
+        $request->addHeader(Headers::$ContentType,$content_type);
41
+    }
42 42
 }
43 43
 class HeaderAuthSigner implements Signer{
44
-	public function sign(Ks3Request $request,$args=array()){
45
-		$log = "stringToSing->\r\n";
46
-		$date = gmdate('D, d M Y H:i:s \G\M\T');
47
-		$request->addHeader(Headers::$Date, $date);
44
+    public function sign(Ks3Request $request,$args=array()){
45
+        $log = "stringToSing->\r\n";
46
+        $date = gmdate('D, d M Y H:i:s \G\M\T');
47
+        $request->addHeader(Headers::$Date, $date);
48 48
 
49
-		$ak = $args["accessKey"];
50
-		$sk = $args["secretKey"];
51
-		if(empty($ak)){
52
-			throw new Ks3ClientException("you should provide accessKey");
53
-		}
54
-		if(empty($sk)){
55
-			throw new Ks3ClientException("you should provide secretKey");
56
-		}
57
-		$authration = "KSS ";
58
-		$signList = array(
59
-			$request->method,
60
-			$request->getHeader(Headers::$ContentMd5),
61
-			$request->getHeader(Headers::$ContentType),
62
-			$date
63
-			);
64
-		$headers = AuthUtils::canonicalizedKssHeaders($request);
65
-		$resource = AuthUtils::canonicalizedResource($request);
66
-		if(!empty($headers)){
67
-			array_push($signList,$headers);
68
-		}
69
-		array_push($signList,$resource);
70
-		$stringToSign = join("\n",$signList);
71
-		$log.= $stringToSign;
72
-		$signature = base64_encode(hash_hmac('sha1', $stringToSign, $sk, true));
49
+        $ak = $args["accessKey"];
50
+        $sk = $args["secretKey"];
51
+        if(empty($ak)){
52
+            throw new Ks3ClientException("you should provide accessKey");
53
+        }
54
+        if(empty($sk)){
55
+            throw new Ks3ClientException("you should provide secretKey");
56
+        }
57
+        $authration = "KSS ";
58
+        $signList = array(
59
+            $request->method,
60
+            $request->getHeader(Headers::$ContentMd5),
61
+            $request->getHeader(Headers::$ContentType),
62
+            $date
63
+            );
64
+        $headers = AuthUtils::canonicalizedKssHeaders($request);
65
+        $resource = AuthUtils::canonicalizedResource($request);
66
+        if(!empty($headers)){
67
+            array_push($signList,$headers);
68
+        }
69
+        array_push($signList,$resource);
70
+        $stringToSign = join("\n",$signList);
71
+        $log.= $stringToSign;
72
+        $signature = base64_encode(hash_hmac('sha1', $stringToSign, $sk, true));
73 73
 
74
-		$authration.=$ak.":".$signature;
75
-		$request->addHeader(Headers::$Authorization, $authration);
76
-		return $log;
77
-	}
74
+        $authration.=$ak.":".$signature;
75
+        $request->addHeader(Headers::$Authorization, $authration);
76
+        return $log;
77
+    }
78 78
 }
79 79
 class QueryAuthSigner implements Signer{
80
-	public function sign(Ks3Request $request,$args=array()){
81
-		$log = "stringToSing->\r\n";
82
-		$ak = $args["accessKey"];
83
-		$sk = $args["secretKey"];
84
-		$expires = $args["args"]["Options"]["Expires"];
85
-		$expiresSencond = time()+$expires;
80
+    public function sign(Ks3Request $request,$args=array()){
81
+        $log = "stringToSing->\r\n";
82
+        $ak = $args["accessKey"];
83
+        $sk = $args["secretKey"];
84
+        $expires = $args["args"]["Options"]["Expires"];
85
+        $expiresSencond = time()+$expires;
86 86
 
87
-		$resource = AuthUtils::canonicalizedResource($request);
88
-		$signList = array(
89
-			$request->method,
90
-			$request->getHeader(Headers::$ContentMd5),
91
-			$request->getHeader(Headers::$ContentType),
92
-			$expiresSencond
93
-			);
94
-		$headers = AuthUtils::canonicalizedKssHeaders($request);
95
-		$resource = AuthUtils::canonicalizedResource($request);
96
-		if(!empty($headers)){
97
-			array_push($signList,$headers);
98
-		}
99
-		array_push($signList,$resource);
87
+        $resource = AuthUtils::canonicalizedResource($request);
88
+        $signList = array(
89
+            $request->method,
90
+            $request->getHeader(Headers::$ContentMd5),
91
+            $request->getHeader(Headers::$ContentType),
92
+            $expiresSencond
93
+            );
94
+        $headers = AuthUtils::canonicalizedKssHeaders($request);
95
+        $resource = AuthUtils::canonicalizedResource($request);
96
+        if(!empty($headers)){
97
+            array_push($signList,$headers);
98
+        }
99
+        array_push($signList,$resource);
100 100
 
101
-		$stringToSign = join("\n",$signList);
102
-		$log.= $stringToSign;
103
-		$signature = base64_encode(hash_hmac('sha1', $stringToSign, $sk, true));
104
-		$request->addQueryParams("KSSAccessKeyId",$ak);
105
-		$request->addQueryParams("Signature",$signature);
106
-		$request->addQueryParams("Expires",$expiresSencond);
107
-		return $log;
108
-	}
101
+        $stringToSign = join("\n",$signList);
102
+        $log.= $stringToSign;
103
+        $signature = base64_encode(hash_hmac('sha1', $stringToSign, $sk, true));
104
+        $request->addQueryParams("KSSAccessKeyId",$ak);
105
+        $request->addQueryParams("Signature",$signature);
106
+        $request->addQueryParams("Expires",$expiresSencond);
107
+        return $log;
108
+    }
109 109
 }
110 110
 class ACLSigner implements Signer{
111
-	public function sign(Ks3Request $request,$args=array()){
112
-		$args = $args["args"];
113
-		if(isset($args["ACL"])){
114
-			$acl = $args["ACL"];
115
-			if(!in_array($acl, Consts::$Acl)){
116
-				throw new Ks3ClientException("unsupport acl :".$acl);
117
-			}else{
118
-				$request->addHeader(Headers::$Acl,$acl);
119
-			}
120
-		}
121
-		if(isset($args["ACP"])){
111
+    public function sign(Ks3Request $request,$args=array()){
112
+        $args = $args["args"];
113
+        if(isset($args["ACL"])){
114
+            $acl = $args["ACL"];
115
+            if(!in_array($acl, Consts::$Acl)){
116
+                throw new Ks3ClientException("unsupport acl :".$acl);
117
+            }else{
118
+                $request->addHeader(Headers::$Acl,$acl);
119
+            }
120
+        }
121
+        if(isset($args["ACP"])){
122 122
 
123
-		}
124
-	}
123
+        }
124
+    }
125 125
 }
126 126
 class ContentMD5Signer implements Signer{
127
-	public function sign(Ks3Request $request,$args=array()){
128
-		$args = $args["args"];
129
-		$contentmd5 = "";
130
-		if(isset($args["ObjectMeta"][Headers::$ContentMd5])){
131
-			$contentmd5 = $args["ObjectMeta"][Headers::$ContentMd5];
132
-		}
133
-		if(empty($contentmd5)){
134
-			$body = $request->body;
135
-			if(!empty($body)){
136
-				$length = $request->getHeader(Headers::$ContentLength);
137
-				if(empty($length)){
138
-					if(isset($args["ObjectMeta"][Headers::$ContentLength]))
139
-						$length = $args["ObjectMeta"][Headers::$ContentLength];
140
-				}
141
-				if(!empty($length)){
142
-					$body = substr($body,0,$length);
143
-				}
144
-				$contentmd5 = Utils::hex_to_base64(md5($body));
145
-			}
146
-		}
147
-		if(!empty($contentmd5))
148
-			$request->addHeader(Headers::$ContentMd5,$contentmd5);
149
-	}
127
+    public function sign(Ks3Request $request,$args=array()){
128
+        $args = $args["args"];
129
+        $contentmd5 = "";
130
+        if(isset($args["ObjectMeta"][Headers::$ContentMd5])){
131
+            $contentmd5 = $args["ObjectMeta"][Headers::$ContentMd5];
132
+        }
133
+        if(empty($contentmd5)){
134
+            $body = $request->body;
135
+            if(!empty($body)){
136
+                $length = $request->getHeader(Headers::$ContentLength);
137
+                if(empty($length)){
138
+                    if(isset($args["ObjectMeta"][Headers::$ContentLength]))
139
+                        $length = $args["ObjectMeta"][Headers::$ContentLength];
140
+                }
141
+                if(!empty($length)){
142
+                    $body = substr($body,0,$length);
143
+                }
144
+                $contentmd5 = Utils::hex_to_base64(md5($body));
145
+            }
146
+        }
147
+        if(!empty($contentmd5))
148
+            $request->addHeader(Headers::$ContentMd5,$contentmd5);
149
+    }
150 150
 }
151 151
 class ContentLengthSigner implements Signer{
152
-	public function sign(Ks3Request $request,$args=array()){
153
-		$args = $args["args"];
154
-		$contentlength = "";
155
-		if(isset($args["ObjectMeta"][Headers::$ContentLength])){
156
-			$contentlength = $args["ObjectMeta"][Headers::$ContentLength];
157
-		}
158
-		if(empty($contentlength)){
159
-			$body = $request->body;
160
-			if(!empty($body)){
161
-				$contentlength = strlen($body);
162
-			}
163
-		}
164
-		if(!empty($contentlength))
165
-			$request->addHeader(Headers::$ContentLength,$contentlength);
166
-	}
152
+    public function sign(Ks3Request $request,$args=array()){
153
+        $args = $args["args"];
154
+        $contentlength = "";
155
+        if(isset($args["ObjectMeta"][Headers::$ContentLength])){
156
+            $contentlength = $args["ObjectMeta"][Headers::$ContentLength];
157
+        }
158
+        if(empty($contentlength)){
159
+            $body = $request->body;
160
+            if(!empty($body)){
161
+                $contentlength = strlen($body);
162
+            }
163
+        }
164
+        if(!empty($contentlength))
165
+            $request->addHeader(Headers::$ContentLength,$contentlength);
166
+    }
167 167
 }
168 168
 class ObjectMetaSigner implements Signer{
169
-	public function sign(Ks3Request $request,$args=array()){
170
-		$args = $args["args"];
171
-		if(isset($args["ObjectMeta"])){
172
-			$ObjectMeta = $args["ObjectMeta"];
173
-			if(is_array($ObjectMeta)){
174
-				foreach ($ObjectMeta as $key => $value) {
175
-					if(in_array($key,Consts::$ObjectMeta)&&!empty($value)){
176
-						$request->addHeader($key,$value);
177
-					}
178
-				}
179
-			}
180
-		}
181
-	}
169
+    public function sign(Ks3Request $request,$args=array()){
170
+        $args = $args["args"];
171
+        if(isset($args["ObjectMeta"])){
172
+            $ObjectMeta = $args["ObjectMeta"];
173
+            if(is_array($ObjectMeta)){
174
+                foreach ($ObjectMeta as $key => $value) {
175
+                    if(in_array($key,Consts::$ObjectMeta)&&!empty($value)){
176
+                        $request->addHeader($key,$value);
177
+                    }
178
+                }
179
+            }
180
+        }
181
+    }
182 182
 }
183 183
 class MultipartObjectMetaSigner implements Signer{
184
-	public function sign(Ks3Request $request,$args=array()){
185
-		$args = $args["args"];
186
-		if(isset($args["ObjectMeta"])){
187
-			$ObjectMeta = $args["ObjectMeta"];
188
-			if(is_array($ObjectMeta)){
189
-				foreach ($ObjectMeta as $key => $value) {
190
-					if(in_array($key,Consts::$MultipartObjectMeta)&&!empty($value)){
191
-						$request->addHeader($key,$value);
192
-					}
193
-				}
194
-			}
195
-		}
196
-	}
184
+    public function sign(Ks3Request $request,$args=array()){
185
+        $args = $args["args"];
186
+        if(isset($args["ObjectMeta"])){
187
+            $ObjectMeta = $args["ObjectMeta"];
188
+            if(is_array($ObjectMeta)){
189
+                foreach ($ObjectMeta as $key => $value) {
190
+                    if(in_array($key,Consts::$MultipartObjectMeta)&&!empty($value)){
191
+                        $request->addHeader($key,$value);
192
+                    }
193
+                }
194
+            }
195
+        }
196
+    }
197 197
 }
198 198
 class UserMetaSigner implements Signer{
199
-	public function sign(Ks3Request $request,$args=array()){
200
-		$args = $args["args"];
201
-		if(isset($args["UserMeta"])){
202
-			$UserMeta = $args["UserMeta"];
203
-			if(is_array($UserMeta)){
204
-				foreach ($UserMeta as $key => $value) {
205
-					if (substr(strtolower($key), 0, 10) === Consts::$UserMetaPrefix){
206
-						$request->addHeader($key,$value);
207
-					}
208
-				}
209
-			}
210
-		}
211
-	}
199
+    public function sign(Ks3Request $request,$args=array()){
200
+        $args = $args["args"];
201
+        if(isset($args["UserMeta"])){
202
+            $UserMeta = $args["UserMeta"];
203
+            if(is_array($UserMeta)){
204
+                foreach ($UserMeta as $key => $value) {
205
+                    if (substr(strtolower($key), 0, 10) === Consts::$UserMetaPrefix){
206
+                        $request->addHeader($key,$value);
207
+                    }
208
+                }
209
+            }
210
+        }
211
+    }
212 212
 }
213 213
 class CopySourceSigner implements Signer{
214
-	public function sign(Ks3Request $request,$args=array()){
215
-		$args = $args["args"];
216
-		if(isset($args["CopySource"])){
217
-			$CopySource = $args["CopySource"];
218
-			if(is_array($CopySource)){
219
-				if(!isset($CopySource["Bucket"]))
220
-					throw new Ks3ClientException("you should provide copy source bucket");
221
-				if(!isset($CopySource["Key"]))
222
-					throw new Ks3ClientException("you should provide copy source key");
223
-				$bucket = $CopySource["Bucket"];
224
-				$key = Utils::encodeUrl($CopySource["Key"]);
225
-				$request->addHeader(Headers::$CopySource,"/".$bucket."/".$key);
226
-			}
227
-		}
228
-	}
214
+    public function sign(Ks3Request $request,$args=array()){
215
+        $args = $args["args"];
216
+        if(isset($args["CopySource"])){
217
+            $CopySource = $args["CopySource"];
218
+            if(is_array($CopySource)){
219
+                if(!isset($CopySource["Bucket"]))
220
+                    throw new Ks3ClientException("you should provide copy source bucket");
221
+                if(!isset($CopySource["Key"]))
222
+                    throw new Ks3ClientException("you should provide copy source key");
223
+                $bucket = $CopySource["Bucket"];
224
+                $key = Utils::encodeUrl($CopySource["Key"]);
225
+                $request->addHeader(Headers::$CopySource,"/".$bucket."/".$key);
226
+            }
227
+        }
228
+    }
229 229
 }
230 230
 class StreamUploadSigner implements Signer{
231
-	public function sign(Ks3Request $request,$args=array()){
232
-		$args = $args["args"];
233
-		if(isset($args["Content"])&&is_array($args["Content"])&&isset($args["Content"]["content"])){
234
-			$content = $args["Content"]["content"];
235
-			$seek_position = 0;
236
-			$resourceLength = 0;
237
-			$length = -1;
238
-			$isFile = FALSE;
231
+    public function sign(Ks3Request $request,$args=array()){
232
+        $args = $args["args"];
233
+        if(isset($args["Content"])&&is_array($args["Content"])&&isset($args["Content"]["content"])){
234
+            $content = $args["Content"]["content"];
235
+            $seek_position = 0;
236
+            $resourceLength = 0;
237
+            $length = -1;
238
+            $isFile = FALSE;
239 239
 
240
-			if (!is_resource($content)){
241
-				$isFile = TRUE;
242
-				//如果之前用户已经转化为GBK则不转换
243
-				if(Utils::chk_chinese($content)&&!Utils::check_char($content)){
244
-					$content = iconv('utf-8','gbk',$content);
245
-				}
246
-				if(!file_exists($content))
247
-					throw new Ks3ClientException("the specified file does not exist ");
248
-				$length = Utils::getFileSize($content);
249
-				$content = fopen($content,"r");
250
-			}else{
251
-				$stats = fstat($content);
252
-				if ($stats && $stats["size"] >= 0){
253
-					$length = $stats["size"];	
254
-				}
255
-			}
256
-			//之所以取resourceLength是为了防止Content-Length大于实际数据的大小,导致一直等待。
257
-			$resourceLength = $length;
258
-			//优先取用户设置seek_position,没有的话取ftell
259
-			if(isset($args["Content"]["seek_position"])&&$args["Content"]["seek_position"]>0){
260
-				$seek_position = $args["Content"]["seek_position"];
261
-			}else if(!$isFile){
262
-				$seek_position = ftell($content);
263
-				if($seek_position<0)
264
-					$seek_position = 0;
265
-				fseek($content,0);
266
-			}
240
+            if (!is_resource($content)){
241
+                $isFile = TRUE;
242
+                //如果之前用户已经转化为GBK则不转换
243
+                if(Utils::chk_chinese($content)&&!Utils::check_char($content)){
244
+                    $content = iconv('utf-8','gbk',$content);
245
+                }
246
+                if(!file_exists($content))
247
+                    throw new Ks3ClientException("the specified file does not exist ");
248
+                $length = Utils::getFileSize($content);
249
+                $content = fopen($content,"r");
250
+            }else{
251
+                $stats = fstat($content);
252
+                if ($stats && $stats["size"] >= 0){
253
+                    $length = $stats["size"];	
254
+                }
255
+            }
256
+            //之所以取resourceLength是为了防止Content-Length大于实际数据的大小,导致一直等待。
257
+            $resourceLength = $length;
258
+            //优先取用户设置seek_position,没有的话取ftell
259
+            if(isset($args["Content"]["seek_position"])&&$args["Content"]["seek_position"]>0){
260
+                $seek_position = $args["Content"]["seek_position"];
261
+            }else if(!$isFile){
262
+                $seek_position = ftell($content);
263
+                if($seek_position<0)
264
+                    $seek_position = 0;
265
+                fseek($content,0);
266
+            }
267 267
 
268
-			$lengthInMeta = -1;
269
-			if(isset($args["ObjectMeta"]["Content-Length"])){
270
-				$lengthInMeta = $args["ObjectMeta"]["Content-Length"];
271
-			}
272
-			if($lengthInMeta > 0){
273
-				$length = $lengthInMeta;
274
-			}else if($resourceLength > 0){
275
-				//根据seek_position计算实际长度
276
-				$length = $resourceLength - $seek_position;
277
-			}
278
-			if($length <= 0)
279
-				throw new Ks3ClientException("calculate content length failed,unexpected contetn length ".$length);
280
-			$request->read_stream = $content;
281
-			$request->addHeader(Headers::$ContentLength,$length);
282
-			$request->seek_position = $seek_position;
283
-		}else{
284
-			throw new Ks3ClientException("please specifie upload content in args");
285
-		}
286
-	}
268
+            $lengthInMeta = -1;
269
+            if(isset($args["ObjectMeta"]["Content-Length"])){
270
+                $lengthInMeta = $args["ObjectMeta"]["Content-Length"];
271
+            }
272
+            if($lengthInMeta > 0){
273
+                $length = $lengthInMeta;
274
+            }else if($resourceLength > 0){
275
+                //根据seek_position计算实际长度
276
+                $length = $resourceLength - $seek_position;
277
+            }
278
+            if($length <= 0)
279
+                throw new Ks3ClientException("calculate content length failed,unexpected contetn length ".$length);
280
+            $request->read_stream = $content;
281
+            $request->addHeader(Headers::$ContentLength,$length);
282
+            $request->seek_position = $seek_position;
283
+        }else{
284
+            throw new Ks3ClientException("please specifie upload content in args");
285
+        }
286
+    }
287 287
 }
288 288
 class RangeSigner{
289
-	public function sign(Ks3Request $request,$args=array()){
290
-		$args = $args["args"];
291
-		if(isset($args["Range"])){
292
-			$Range = $args["Range"];
293
-			if(is_array($Range)){
294
-				$start = $Range["start"];
295
-				$end = $Range["end"];
296
-				$range = "bytes=".$start."-".$end;
297
-				$request->addHeader(Headers::$Range,$range);
298
-			}else
299
-				$request->addHeader(Headers::$Range,$Range);
300
-		}
301
-	}
289
+    public function sign(Ks3Request $request,$args=array()){
290
+        $args = $args["args"];
291
+        if(isset($args["Range"])){
292
+            $Range = $args["Range"];
293
+            if(is_array($Range)){
294
+                $start = $Range["start"];
295
+                $end = $Range["end"];
296
+                $range = "bytes=".$start."-".$end;
297
+                $request->addHeader(Headers::$Range,$range);
298
+            }else
299
+                $request->addHeader(Headers::$Range,$Range);
300
+        }
301
+    }
302 302
 }
303 303
 class GetObjectSigner{
304
-	public function sign(Ks3Request $request,$args=array()){
305
-		$args = $args["args"];
306
-		if(isset($args["WriteTo"])){
307
-			$WriteTo = $args["WriteTo"];
308
-			if(is_resource($WriteTo)){
309
-				$request->write_stream = $WriteTo;
310
-			}else{
311
-				//如果之前用户已经转化为GBK则不转换
312
-				if(Utils::chk_chinese($WriteTo)&&!Utils::check_char($WriteTo)){
313
-					$WriteTo = iconv('utf-8','gbk',$WriteTo);
314
-				}
315
-				$request->write_stream = fopen($WriteTo,"w");
316
-			}
317
-		}
318
-	}
304
+    public function sign(Ks3Request $request,$args=array()){
305
+        $args = $args["args"];
306
+        if(isset($args["WriteTo"])){
307
+            $WriteTo = $args["WriteTo"];
308
+            if(is_resource($WriteTo)){
309
+                $request->write_stream = $WriteTo;
310
+            }else{
311
+                //如果之前用户已经转化为GBK则不转换
312
+                if(Utils::chk_chinese($WriteTo)&&!Utils::check_char($WriteTo)){
313
+                    $WriteTo = iconv('utf-8','gbk',$WriteTo);
314
+                }
315
+                $request->write_stream = fopen($WriteTo,"w");
316
+            }
317
+        }
318
+    }
319 319
 }
320 320
 class AdpSigner{
321
-	public function sign(Ks3Request $request,$args=array()){
322
-		$args = $args["args"];
323
-		if(isset($args["Adp"])){
324
-			$AdpConf = $args["Adp"];
325
-			if(is_array($AdpConf)){
326
-				if(isset($AdpConf["NotifyURL"])){
327
-					$NotifyURL = $AdpConf["NotifyURL"];
328
-				}else{
329
-					throw new Ks3ClientException("adp should provide NotifyURL");
330
-				}
331
-				if(isset($AdpConf["Adps"])){
332
-					$Adps = $AdpConf["Adps"];
333
-				}else{
334
-					throw new Ks3ClientException("adp should provide Adps");
335
-				}
336
-				$AdpString = "";
337
-				foreach ($Adps as $Adp) {
338
-					if(is_array($Adp)){
339
-						if(!isset($Adp["Command"])){
340
-							throw new Ks3ClientException("command is needed in adp");
341
-						}
342
-						$command = $Adp["Command"];
343
-						$bucket = NULL;
344
-						$key = NULL;
345
-						if(isset($Adp["Bucket"])){
346
-							$bucket = $Adp["Bucket"];
347
-						}
348
-						if(isset($Adp["Key"])){
349
-							$key = $Adp["Key"];
350
-						}
351
-						$AdpString.=$command;
352
-						if(!(empty($bucket)&&empty($key))){
353
-							if(empty($bucket)){
354
-								$AdpString.="|tag=saveas&object=".base64_encode($key);
355
-							}elseif (empty($key)) {
356
-								$AdpString.="|tag=saveas&bucket=".$bucket;
357
-							}else{
358
-								$AdpString.="|tag=saveas&bucket=".$bucket."&"."object=".base64_encode($key);
359
-							}
360
-						}
361
-						$AdpString.=";";
362
-					}
363
-				}
364
-				if(!empty($AdpString)&&!empty($NotifyURL)){
365
-					$request->addHeader(Headers::$AsynchronousProcessingList,$AdpString);
366
-					$request->addHeader(Headers::$NotifyURL,$NotifyURL);
367
-				}
368
-			}
369
-		}
370
-	}
321
+    public function sign(Ks3Request $request,$args=array()){
322
+        $args = $args["args"];
323
+        if(isset($args["Adp"])){
324
+            $AdpConf = $args["Adp"];
325
+            if(is_array($AdpConf)){
326
+                if(isset($AdpConf["NotifyURL"])){
327
+                    $NotifyURL = $AdpConf["NotifyURL"];
328
+                }else{
329
+                    throw new Ks3ClientException("adp should provide NotifyURL");
330
+                }
331
+                if(isset($AdpConf["Adps"])){
332
+                    $Adps = $AdpConf["Adps"];
333
+                }else{
334
+                    throw new Ks3ClientException("adp should provide Adps");
335
+                }
336
+                $AdpString = "";
337
+                foreach ($Adps as $Adp) {
338
+                    if(is_array($Adp)){
339
+                        if(!isset($Adp["Command"])){
340
+                            throw new Ks3ClientException("command is needed in adp");
341
+                        }
342
+                        $command = $Adp["Command"];
343
+                        $bucket = NULL;
344
+                        $key = NULL;
345
+                        if(isset($Adp["Bucket"])){
346
+                            $bucket = $Adp["Bucket"];
347
+                        }
348
+                        if(isset($Adp["Key"])){
349
+                            $key = $Adp["Key"];
350
+                        }
351
+                        $AdpString.=$command;
352
+                        if(!(empty($bucket)&&empty($key))){
353
+                            if(empty($bucket)){
354
+                                $AdpString.="|tag=saveas&object=".base64_encode($key);
355
+                            }elseif (empty($key)) {
356
+                                $AdpString.="|tag=saveas&bucket=".$bucket;
357
+                            }else{
358
+                                $AdpString.="|tag=saveas&bucket=".$bucket."&"."object=".base64_encode($key);
359
+                            }
360
+                        }
361
+                        $AdpString.=";";
362
+                    }
363
+                }
364
+                if(!empty($AdpString)&&!empty($NotifyURL)){
365
+                    $request->addHeader(Headers::$AsynchronousProcessingList,$AdpString);
366
+                    $request->addHeader(Headers::$NotifyURL,$NotifyURL);
367
+                }
368
+            }
369
+        }
370
+    }
371 371
 }
372 372
 class CallBackSigner{
373
-	public function sign(Ks3Request $request,$args=array()){
374
-		$args = $args["args"];
375
-		if(isset($args["CallBack"])&&is_array($args["CallBack"])){
376
-			$CallBackConf = $args["CallBack"];
377
-			$url = NULL;
378
-			$body = NULL;
379
-			if(isset($CallBackConf["Url"])){
380
-				$url = $CallBackConf["Url"];
381
-			}
382
-			if(empty($url))
383
-				throw new Ks3ClientException("Url is needed in CallBack");
384
-			if(isset($CallBackConf["BodyMagicVariables"])){
385
-				if(is_array($CallBackConf["BodyMagicVariables"])){
386
-					$magics = $CallBackConf["BodyMagicVariables"];
387
-					foreach ($magics as $key => $value) {
388
-						if(in_array($value,Consts::$CallBackMagics))
389
-							$body.=$key."=\${".$value."}&";
390
-					}
391
-				}
392
-			}
393
-			if(isset($CallBackConf["BodyVariables"])){
394
-				if(is_array($CallBackConf["BodyVariables"])){
395
-					$variables = $CallBackConf["BodyVariables"];
396
-					foreach ($variables as $key => $value) {
397
-						$body.=$key."=\${kss-".$key."}&";
398
-						$request->addHeader("kss-".$key,$value);
399
-					}
400
-				}
401
-			}
402
-			if(!empty($body)){
403
-				$body=substr($body,0,strlen($body)-1);
404
-				$request->addHeader(Headers::$XKssCallbackBody,$body);
405
-			}
406
-			$request->addHeader(Headers::$XKssCallbackUrl,$url);
407
-		}
408
-	}
373
+    public function sign(Ks3Request $request,$args=array()){
374
+        $args = $args["args"];
375
+        if(isset($args["CallBack"])&&is_array($args["CallBack"])){
376
+            $CallBackConf = $args["CallBack"];
377
+            $url = NULL;
378
+            $body = NULL;
379
+            if(isset($CallBackConf["Url"])){
380
+                $url = $CallBackConf["Url"];
381
+            }
382
+            if(empty($url))
383
+                throw new Ks3ClientException("Url is needed in CallBack");
384
+            if(isset($CallBackConf["BodyMagicVariables"])){
385
+                if(is_array($CallBackConf["BodyMagicVariables"])){
386
+                    $magics = $CallBackConf["BodyMagicVariables"];
387
+                    foreach ($magics as $key => $value) {
388
+                        if(in_array($value,Consts::$CallBackMagics))
389
+                            $body.=$key."=\${".$value."}&";
390
+                    }
391
+                }
392
+            }
393
+            if(isset($CallBackConf["BodyVariables"])){
394
+                if(is_array($CallBackConf["BodyVariables"])){
395
+                    $variables = $CallBackConf["BodyVariables"];
396
+                    foreach ($variables as $key => $value) {
397
+                        $body.=$key."=\${kss-".$key."}&";
398
+                        $request->addHeader("kss-".$key,$value);
399
+                    }
400
+                }
401
+            }
402
+            if(!empty($body)){
403
+                $body=substr($body,0,strlen($body)-1);
404
+                $request->addHeader(Headers::$XKssCallbackBody,$body);
405
+            }
406
+            $request->addHeader(Headers::$XKssCallbackUrl,$url);
407
+        }
408
+    }
409 409
 }
410 410
 class SSESigner{
411
-	public function sign(Ks3Request $request,$args=array()){
412
-		$args = $args["args"];
413
-		if(isset($args["SSE"])){
414
-			if(isset($args["SSE"]["Algm"]))
415
-				$algm = $args["SSE"]["Algm"];
416
-			if(isset($args["SSE"]["KMSId"]))
417
-				$id = $args["SSE"]["KMSId"];
418
-			if(!empty($algm)){		
419
-				$request->addHeader(Headers::$SSEAlgm,$algm);
420
-				if(!empty($id))
421
-					$request->addHeader(Headers::$SSEKMSId,$id);
422
-			}
423
-		}
424
-	}
411
+    public function sign(Ks3Request $request,$args=array()){
412
+        $args = $args["args"];
413
+        if(isset($args["SSE"])){
414
+            if(isset($args["SSE"]["Algm"]))
415
+                $algm = $args["SSE"]["Algm"];
416
+            if(isset($args["SSE"]["KMSId"]))
417
+                $id = $args["SSE"]["KMSId"];
418
+            if(!empty($algm)){		
419
+                $request->addHeader(Headers::$SSEAlgm,$algm);
420
+                if(!empty($id))
421
+                    $request->addHeader(Headers::$SSEKMSId,$id);
422
+            }
423
+        }
424
+    }
425 425
 }
426 426
 class SSECSigner{
427
-	public function sign(Ks3Request $request,$args=array()){
428
-		$args = $args["args"];
429
-		if(isset($args["SSEC"])){
430
-			if(isset($args["SSEC"]["Algm"]))
431
-				$algm = $args["SSEC"]["Algm"];
432
-			if(isset($args["SSEC"]["Key"]))
433
-				$key = $args["SSEC"]["Key"];
434
-			if(isset($args["SSEC"]["KeyBase64"]))
435
-				$keybase64 = $args["SSEC"]["KeyBase64"];
436
-			if(isset($args["SSEC"]["KeyMD5"]))
437
-				$md5 = $args["SSEC"]["KeyMD5"];
438
-			if(!empty($key)||!empty($keybase64)){
439
-				if(empty($key))
440
-					$key = base64_decode($keybase64);
441
-				if(empty($algm))
442
-					$algm = Consts::$SSEDefaultAlgm;
443
-				if(empty($md5))
444
-					$md5 = Utils::hex_to_base64(md5($key));
427
+    public function sign(Ks3Request $request,$args=array()){
428
+        $args = $args["args"];
429
+        if(isset($args["SSEC"])){
430
+            if(isset($args["SSEC"]["Algm"]))
431
+                $algm = $args["SSEC"]["Algm"];
432
+            if(isset($args["SSEC"]["Key"]))
433
+                $key = $args["SSEC"]["Key"];
434
+            if(isset($args["SSEC"]["KeyBase64"]))
435
+                $keybase64 = $args["SSEC"]["KeyBase64"];
436
+            if(isset($args["SSEC"]["KeyMD5"]))
437
+                $md5 = $args["SSEC"]["KeyMD5"];
438
+            if(!empty($key)||!empty($keybase64)){
439
+                if(empty($key))
440
+                    $key = base64_decode($keybase64);
441
+                if(empty($algm))
442
+                    $algm = Consts::$SSEDefaultAlgm;
443
+                if(empty($md5))
444
+                    $md5 = Utils::hex_to_base64(md5($key));
445 445
 
446
-				$request->addHeader(Headers::$SSECAlgm,$algm);
447
-				$request->addHeader(Headers::$SSECKey,base64_encode($key));
448
-				$request->addHeader(Headers::$SSECMD5,$md5);
449
-			}
450
-		}
451
-	}	
446
+                $request->addHeader(Headers::$SSECAlgm,$algm);
447
+                $request->addHeader(Headers::$SSECKey,base64_encode($key));
448
+                $request->addHeader(Headers::$SSECMD5,$md5);
449
+            }
450
+        }
451
+    }	
452 452
 }
453 453
 class SSECSourceSigner{
454
-	public function sign(Ks3Request $request,$args=array()){
455
-		$args = $args["args"];
456
-		if(isset($args["SSECSource"])){
457
-			if(isset($args["SSECSource"]["Algm"]))
458
-				$algm = $args["SSECSource"]["Algm"];
459
-			if(isset($args["SSECSource"]["Key"]))
460
-				$key = $args["SSECSource"]["Key"];
461
-			if(isset($args["SSECSource"]["KeyBase64"]))
462
-				$keybase64 = $args["SSECSource"]["KeyBase64"];
463
-			if(isset($args["SSECSource"]["KeyMD5"]))
464
-				$md5 = $args["SSECSource"]["KeyMD5"];
465
-			if(!empty($key)||!empty($keybase64)){
466
-				if(empty($key))
467
-					$key = base64_decode($keybase64);
468
-				if(empty($algm))
469
-					$algm = Consts::$SSEDefaultAlgm;
470
-				if(empty($md5))
471
-					$md5 = Utils::hex_to_base64(md5($key));
454
+    public function sign(Ks3Request $request,$args=array()){
455
+        $args = $args["args"];
456
+        if(isset($args["SSECSource"])){
457
+            if(isset($args["SSECSource"]["Algm"]))
458
+                $algm = $args["SSECSource"]["Algm"];
459
+            if(isset($args["SSECSource"]["Key"]))
460
+                $key = $args["SSECSource"]["Key"];
461
+            if(isset($args["SSECSource"]["KeyBase64"]))
462
+                $keybase64 = $args["SSECSource"]["KeyBase64"];
463
+            if(isset($args["SSECSource"]["KeyMD5"]))
464
+                $md5 = $args["SSECSource"]["KeyMD5"];
465
+            if(!empty($key)||!empty($keybase64)){
466
+                if(empty($key))
467
+                    $key = base64_decode($keybase64);
468
+                if(empty($algm))
469
+                    $algm = Consts::$SSEDefaultAlgm;
470
+                if(empty($md5))
471
+                    $md5 = Utils::hex_to_base64(md5($key));
472 472
 
473
-				$request->addHeader(Headers::$SSECSourceAlgm,$algm);
474
-				$request->addHeader(Headers::$SSECSourceKey,base64_encode($key));
475
-				$request->addHeader(Headers::$SSECSourceMD5,$md5);
476
-			}
477
-		}
478
-	}
473
+                $request->addHeader(Headers::$SSECSourceAlgm,$algm);
474
+                $request->addHeader(Headers::$SSECSourceKey,base64_encode($key));
475
+                $request->addHeader(Headers::$SSECSourceMD5,$md5);
476
+            }
477
+        }
478
+    }
479 479
 }
480 480
 class AllHeaderSigner{
481
-	public function sign(Ks3Request $request,$args=array()){
482
-		$args = $args["args"];
483
-		$headers = isset($args["Headers"])?$args["Headers"]:"";
484
-		if(!empty($headers)&&is_array($headers)){
485
-			foreach ($headers as $key => $value) {
486
-				$request->addHeader($key,$value);
487
-			}
488
-		}
489
-	}
481
+    public function sign(Ks3Request $request,$args=array()){
482
+        $args = $args["args"];
483
+        $headers = isset($args["Headers"])?$args["Headers"]:"";
484
+        if(!empty($headers)&&is_array($headers)){
485
+            foreach ($headers as $key => $value) {
486
+                $request->addHeader($key,$value);
487
+            }
488
+        }
489
+    }
490 490
 }
491 491
 class AuthUtils{
492
-	public static function canonicalizedKssHeaders(Ks3Request $request){
493
-		$header = "";
494
-		$headers = $request->headers;
495
-		ksort($headers,SORT_STRING);
496
-		foreach ( $headers as $header_key => $header_value ) {
497
-			if (substr(strtolower($header_key), 0, 6) === Consts::$KS3HeaderPrefix){
498
-				$header .= "\n".strtolower($header_key) . ':' .$header_value;
499
-			}			
500
-		}
501
-		$header = substr($header, 1);
502
-		return $header;
503
-	}
504
-	public static function canonicalizedResource(Ks3Request $request){
505
-		$resource = "/";
506
-		$bucket = $request->bucket;
507
-		$key = $request->key;
508
-		$subResource = $request->subResource;
509
-		if(!empty($bucket)){
510
-			$resource.=$request->bucket."/";
511
-		}
512
-		if(!empty($key)){
513
-			$resource.=Utils::encodeUrl($request->key);
514
-		}
492
+    public static function canonicalizedKssHeaders(Ks3Request $request){
493
+        $header = "";
494
+        $headers = $request->headers;
495
+        ksort($headers,SORT_STRING);
496
+        foreach ( $headers as $header_key => $header_value ) {
497
+            if (substr(strtolower($header_key), 0, 6) === Consts::$KS3HeaderPrefix){
498
+                $header .= "\n".strtolower($header_key) . ':' .$header_value;
499
+            }			
500
+        }
501
+        $header = substr($header, 1);
502
+        return $header;
503
+    }
504
+    public static function canonicalizedResource(Ks3Request $request){
505
+        $resource = "/";
506
+        $bucket = $request->bucket;
507
+        $key = $request->key;
508
+        $subResource = $request->subResource;
509
+        if(!empty($bucket)){
510
+            $resource.=$request->bucket."/";
511
+        }
512
+        if(!empty($key)){
513
+            $resource.=Utils::encodeUrl($request->key);
514
+        }
515 515
 
516
-		$encodeParams = "";
517
-		$querys = $request->queryParams;
518
-		if(!empty($subResource)){
519
-			$querys[$subResource] = NULL;
520
-		}
521
-		ksort($querys,SORT_STRING);
522
-		foreach ($querys as $key => $value) {
523
-			if(in_array($key,Consts::$SubResource)||in_array($key,Consts::$QueryParam)){
524
-				if(empty($value)){
525
-					$encodeParams.="&".$key;
526
-				}else{
527
-					$encodeParams.="&".$key."=".$value;
528
-				}
529
-			}
530
-		}
531
-		$encodeParams = substr($encodeParams,1);
516
+        $encodeParams = "";
517
+        $querys = $request->queryParams;
518
+        if(!empty($subResource)){
519
+            $querys[$subResource] = NULL;
520
+        }
521
+        ksort($querys,SORT_STRING);
522
+        foreach ($querys as $key => $value) {
523
+            if(in_array($key,Consts::$SubResource)||in_array($key,Consts::$QueryParam)){
524
+                if(empty($value)){
525
+                    $encodeParams.="&".$key;
526
+                }else{
527
+                    $encodeParams.="&".$key."=".$value;
528
+                }
529
+            }
530
+        }
531
+        $encodeParams = substr($encodeParams,1);
532 532
 
533
-		$resource = str_replace("//","/%2F", $resource);
533
+        $resource = str_replace("//","/%2F", $resource);
534 534
 
535
-		if(!empty($encodeParams)){
536
-			$resource.="?".$encodeParams;
537
-		}
538
-		return $resource;
539
-	}
535
+        if(!empty($encodeParams)){
536
+            $resource.="?".$encodeParams;
537
+        }
538
+        return $resource;
539
+    }
540 540
 }
541 541
 ?>
542 542
\ No newline at end of file
Please login to merge, or discard this patch.
src/service/ksyun/bin/core/MessageHolder.php 1 patch
Indentation   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -1,5 +1,5 @@
 block discarded – undo
1 1
 <?php
2 2
 class MessageHolder{
3
-	public $msg;
3
+    public $msg;
4 4
 }
5 5
 ?>
6 6
\ No newline at end of file
Please login to merge, or discard this patch.
src/service/ksyun/bin/core/Ks3Request.class.php 1 patch
Indentation   +76 added lines, -76 removed lines patch added patch discarded remove patch
@@ -2,83 +2,83 @@
 block discarded – undo
2 2
 require_once KS3_API_PATH.DIRECTORY_SEPARATOR."core".DIRECTORY_SEPARATOR."Utils.class.php";
3 3
 
4 4
 class Ks3Request{
5
-	private $bucket;
6
-	private $key;
7
-	private $queryParams=array();
8
-	private $headers=array();
9
-	private $subResource;
10
-	private $method;
11
-	private $endpoint;
12
-	private $scheme;
13
-	private $body;
14
-	private $read_stream;
15
-	private $seek_position;
16
-	private $write_stream;
5
+    private $bucket;
6
+    private $key;
7
+    private $queryParams=array();
8
+    private $headers=array();
9
+    private $subResource;
10
+    private $method;
11
+    private $endpoint;
12
+    private $scheme;
13
+    private $body;
14
+    private $read_stream;
15
+    private $seek_position;
16
+    private $write_stream;
17 17
 
18
-	public function __set($property_name, $value){
19
-		$this->$property_name=$value;
20
-	}
21
-	public function __get($property_name){
22
-		if(isset($this->$property_name))
23
-		{
24
-			return($this->$property_name);
25
-		}else
26
-		{
27
-			return(NULL);
28
-		}
29
-	}
30
-	public function getHeader($key){
31
-		if(isset($this->headers[$key])){
32
-			return  $this->headers[$key];
33
-		}else{
34
-			return(NULL);
35
-		}
36
-	}
37
-	public function addHeader($key,$value){
38
-		$this->headers[$key] = $value;
39
-	}
18
+    public function __set($property_name, $value){
19
+        $this->$property_name=$value;
20
+    }
21
+    public function __get($property_name){
22
+        if(isset($this->$property_name))
23
+        {
24
+            return($this->$property_name);
25
+        }else
26
+        {
27
+            return(NULL);
28
+        }
29
+    }
30
+    public function getHeader($key){
31
+        if(isset($this->headers[$key])){
32
+            return  $this->headers[$key];
33
+        }else{
34
+            return(NULL);
35
+        }
36
+    }
37
+    public function addHeader($key,$value){
38
+        $this->headers[$key] = $value;
39
+    }
40 40
 
41
-	public function getQueryParams($key){
42
-		if(isset($this->queryParams[$key])){
43
-			return  $this->queryParams[$key];
44
-		}else{
45
-			return(NULL);
46
-		}
47
-	}
48
-	public function addQueryParams($key,$value){
49
-		$this->queryParams[$key] = $value;
50
-	}
51
-	public function toUrl($endpoint){
52
-		$url = "";
53
-		$bucket = $this->bucket;
54
-		$key = $this->key;
55
-		$subResource = $this->subResource;
56
-		if(!empty($bucket)){
57
-			if(KS3_API_VHOST){
58
-				$url.=$bucket.".".$endpoint;
59
-			}else{
60
-				$url.=$endpoint."/".$bucket;
61
-			}
62
-		}else{
63
-			$url.=$endpoint;
64
-		}
65
-		if(!empty($key)){
66
-			$url.="/".Utils::encodeUrl($key);
67
-		}
68
-		$url = str_replace("//","/%2F", $url);
69
-		$queryString = "";
70
-		if(!empty($subResource)){
71
-			$queryString.="&".$subResource;
72
-		}
73
-		foreach ($this->queryParams as $key => $value) {
74
-			$queryString.="&".$key."=".rawurlencode($value);
75
-		}
76
-		$queryString = substr($queryString, 1);
77
-		if(!empty($queryString)){
78
-			$url.="?".$queryString;
79
-		}
80
-		$url = $this->scheme.$url;
81
-		return $url;
82
-	}
41
+    public function getQueryParams($key){
42
+        if(isset($this->queryParams[$key])){
43
+            return  $this->queryParams[$key];
44
+        }else{
45
+            return(NULL);
46
+        }
47
+    }
48
+    public function addQueryParams($key,$value){
49
+        $this->queryParams[$key] = $value;
50
+    }
51
+    public function toUrl($endpoint){
52
+        $url = "";
53
+        $bucket = $this->bucket;
54
+        $key = $this->key;
55
+        $subResource = $this->subResource;
56
+        if(!empty($bucket)){
57
+            if(KS3_API_VHOST){
58
+                $url.=$bucket.".".$endpoint;
59
+            }else{
60
+                $url.=$endpoint."/".$bucket;
61
+            }
62
+        }else{
63
+            $url.=$endpoint;
64
+        }
65
+        if(!empty($key)){
66
+            $url.="/".Utils::encodeUrl($key);
67
+        }
68
+        $url = str_replace("//","/%2F", $url);
69
+        $queryString = "";
70
+        if(!empty($subResource)){
71
+            $queryString.="&".$subResource;
72
+        }
73
+        foreach ($this->queryParams as $key => $value) {
74
+            $queryString.="&".$key."=".rawurlencode($value);
75
+        }
76
+        $queryString = substr($queryString, 1);
77
+        if(!empty($queryString)){
78
+            $url.="?".$queryString;
79
+        }
80
+        $url = $this->scheme.$url;
81
+        return $url;
82
+    }
83 83
 }
84 84
 ?>
85 85
\ No newline at end of file
Please login to merge, or discard this patch.
src/service/ksyun/bin/core/Utils.class.php 1 patch
Indentation   +223 added lines, -223 removed lines patch added patch discarded remove patch
@@ -2,234 +2,234 @@
 block discarded – undo
2 2
 require_once KS3_API_PATH.DIRECTORY_SEPARATOR."exceptions".DIRECTORY_SEPARATOR."Exceptions.php";
3 3
 
4 4
 class Utils{
5
-	public static function encodeUrl($url,$path=TRUE){
6
-		$url = rawurlencode($url);
7
-		$url = str_replace("+", "%20", $url);
8
-		$url = str_replace("*", "%2A", $url);
9
-		$url = str_replace("%7A", "~", $url);
10
-		if($path){
11
-			$url = str_replace("%2F", "/", $url);
12
-		}
13
-		return $url;
14
-	}
15
-	public static function hex_to_base64($str){
16
-		$result = '';
5
+    public static function encodeUrl($url,$path=TRUE){
6
+        $url = rawurlencode($url);
7
+        $url = str_replace("+", "%20", $url);
8
+        $url = str_replace("*", "%2A", $url);
9
+        $url = str_replace("%7A", "~", $url);
10
+        if($path){
11
+            $url = str_replace("%2F", "/", $url);
12
+        }
13
+        return $url;
14
+    }
15
+    public static function hex_to_base64($str){
16
+        $result = '';
17 17
 
18
-		for ($i = 0; $i < strlen($str); $i += 2){
19
-			$result .= chr(hexdec(substr($str, $i, 2)));
20
-		}
18
+        for ($i = 0; $i < strlen($str); $i += 2){
19
+            $result .= chr(hexdec(substr($str, $i, 2)));
20
+        }
21 21
 
22
-		return base64_encode($result);
23
-	}
24
-	public static function replaceNS2($str){
25
-		$str = str_replace("<ns2:", "<", $str);
26
-		$str = str_replace("</ns2:", "</", $str);
27
-		return $str;
28
-	}
29
-	public static $mime_types = array (
30
-			'apk' => 'application/vnd.android.package-archive',
31
-			'3gp' => 'video/3gpp', 'ai' => 'application/postscript', 
32
-			'aif' => 'audio/x-aiff', 'aifc' => 'audio/x-aiff', 
33
-			'aiff' => 'audio/x-aiff', 'asc' => 'text/plain', 
34
-			'atom' => 'application/atom+xml', 'au' => 'audio/basic', 
35
-			'avi' => 'video/x-msvideo', 'bcpio' => 'application/x-bcpio', 
36
-			'bin' => 'application/octet-stream', 'bmp' => 'image/bmp', 
37
-			'cdf' => 'application/x-netcdf', 'cgm' => 'image/cgm', 
38
-			'class' => 'application/octet-stream', 
39
-			'cpio' => 'application/x-cpio', 
40
-			'cpt' => 'application/mac-compactpro', 
41
-			'csh' => 'application/x-csh', 'css' => 'text/css', 
42
-			'dcr' => 'application/x-director', 'dif' => 'video/x-dv', 
43
-			'dir' => 'application/x-director', 'djv' => 'image/vnd.djvu', 
44
-			'djvu' => 'image/vnd.djvu', 
45
-			'dll' => 'application/octet-stream', 
46
-			'dmg' => 'application/octet-stream', 
47
-			'dms' => 'application/octet-stream', 
48
-			'doc' => 'application/msword', 'dtd' => 'application/xml-dtd', 
49
-			'dv' => 'video/x-dv', 'dvi' => 'application/x-dvi', 
50
-			'dxr' => 'application/x-director', 
51
-			'eps' => 'application/postscript', 'etx' => 'text/x-setext', 
52
-			'exe' => 'application/octet-stream', 
53
-			'ez' => 'application/andrew-inset', 'flv' => 'video/x-flv', 
54
-			'gif' => 'image/gif', 'gram' => 'application/srgs', 
55
-			'grxml' => 'application/srgs+xml', 
56
-			'gtar' => 'application/x-gtar', 'gz' => 'application/x-gzip', 
57
-			'hdf' => 'application/x-hdf', 
58
-			'hqx' => 'application/mac-binhex40', 'htm' => 'text/html', 
59
-			'html' => 'text/html', 'ice' => 'x-conference/x-cooltalk', 
60
-			'ico' => 'image/x-icon', 'ics' => 'text/calendar', 
61
-			'ief' => 'image/ief', 'ifb' => 'text/calendar', 
62
-			'iges' => 'model/iges', 'igs' => 'model/iges', 
63
-			'jnlp' => 'application/x-java-jnlp-file', 'jp2' => 'image/jp2', 
64
-			'jpe' => 'image/jpeg', 'jpeg' => 'image/jpeg', 
65
-			'jpg' => 'image/jpeg', 'js' => 'application/x-javascript', 
66
-			'kar' => 'audio/midi', 'latex' => 'application/x-latex', 
67
-			'lha' => 'application/octet-stream', 
68
-			'lzh' => 'application/octet-stream', 
69
-			'm3u' => 'audio/x-mpegurl', 'm4a' => 'audio/mp4a-latm', 
70
-			'm4p' => 'audio/mp4a-latm', 'm4u' => 'video/vnd.mpegurl', 
71
-			'm4v' => 'video/x-m4v', 'mac' => 'image/x-macpaint', 
72
-			'man' => 'application/x-troff-man', 
73
-			'mathml' => 'application/mathml+xml', 
74
-			'me' => 'application/x-troff-me', 'mesh' => 'model/mesh', 
75
-			'mid' => 'audio/midi', 'midi' => 'audio/midi', 
76
-			'mif' => 'application/vnd.mif', 'mov' => 'video/quicktime', 
77
-			'movie' => 'video/x-sgi-movie', 'mp2' => 'audio/mpeg', 
78
-			'mp3' => 'audio/mpeg', 'mp4' => 'video/mp4', 
79
-			'mpe' => 'video/mpeg', 'mpeg' => 'video/mpeg', 
80
-			'mpg' => 'video/mpeg', 'mpga' => 'audio/mpeg', 
81
-			'ms' => 'application/x-troff-ms', 'msh' => 'model/mesh', 
82
-			'mxu' => 'video/vnd.mpegurl', 'nc' => 'application/x-netcdf', 
83
-			'oda' => 'application/oda', 'ogg' => 'application/ogg', 
84
-			'ogv' => 'video/ogv', 'pbm' => 'image/x-portable-bitmap', 
85
-			'pct' => 'image/pict', 'pdb' => 'chemical/x-pdb', 
86
-			'pdf' => 'application/pdf', 
87
-			'pgm' => 'image/x-portable-graymap', 
88
-			'pgn' => 'application/x-chess-pgn', 'pic' => 'image/pict', 
89
-			'pict' => 'image/pict', 'png' => 'image/png', 
90
-			'pnm' => 'image/x-portable-anymap', 
91
-			'pnt' => 'image/x-macpaint', 'pntg' => 'image/x-macpaint', 
92
-			'ppm' => 'image/x-portable-pixmap', 
93
-			'ppt' => 'application/vnd.ms-powerpoint', 
94
-			'ps' => 'application/postscript', 'qt' => 'video/quicktime', 
95
-			'qti' => 'image/x-quicktime', 'qtif' => 'image/x-quicktime', 
96
-			'ra' => 'audio/x-pn-realaudio', 
97
-			'ram' => 'audio/x-pn-realaudio', 'ras' => 'image/x-cmu-raster', 
98
-			'rdf' => 'application/rdf+xml', 'rgb' => 'image/x-rgb', 
99
-			'rm' => 'application/vnd.rn-realmedia', 
100
-			'roff' => 'application/x-troff', 'rtf' => 'text/rtf', 
101
-			'rtx' => 'text/richtext', 'sgm' => 'text/sgml', 
102
-			'sgml' => 'text/sgml', 'sh' => 'application/x-sh', 
103
-			'shar' => 'application/x-shar', 'silo' => 'model/mesh', 
104
-			'sit' => 'application/x-stuffit', 
105
-			'skd' => 'application/x-koan', 'skm' => 'application/x-koan', 
106
-			'skp' => 'application/x-koan', 'skt' => 'application/x-koan', 
107
-			'smi' => 'application/smil', 'smil' => 'application/smil', 
108
-			'snd' => 'audio/basic', 'so' => 'application/octet-stream', 
109
-			'spl' => 'application/x-futuresplash', 
110
-			'src' => 'application/x-wais-source', 
111
-			'sv4cpio' => 'application/x-sv4cpio', 
112
-			'sv4crc' => 'application/x-sv4crc', 'svg' => 'image/svg+xml', 
113
-			'swf' => 'application/x-shockwave-flash', 
114
-			't' => 'application/x-troff', 'tar' => 'application/x-tar', 
115
-			'tcl' => 'application/x-tcl', 'tex' => 'application/x-tex', 
116
-			'texi' => 'application/x-texinfo', 
117
-			'texinfo' => 'application/x-texinfo', 'tif' => 'image/tiff', 
118
-			'tiff' => 'image/tiff', 'tr' => 'application/x-troff', 
119
-			'tsv' => 'text/tab-separated-values', 'txt' => 'text/plain', 
120
-			'ustar' => 'application/x-ustar', 
121
-			'vcd' => 'application/x-cdlink', 'vrml' => 'model/vrml', 
122
-			'vxml' => 'application/voicexml+xml', 'wav' => 'audio/x-wav', 
123
-			'wbmp' => 'image/vnd.wap.wbmp', 
124
-			'wbxml' => 'application/vnd.wap.wbxml', 'webm' => 'video/webm', 
125
-			'wml' => 'text/vnd.wap.wml', 
126
-			'wmlc' => 'application/vnd.wap.wmlc', 
127
-			'wmls' => 'text/vnd.wap.wmlscript', 
128
-			'wmlsc' => 'application/vnd.wap.wmlscriptc', 
129
-			'wmv' => 'video/x-ms-wmv', 'wrl' => 'model/vrml', 
130
-			'xbm' => 'image/x-xbitmap', 'xht' => 'application/xhtml+xml', 
131
-			'xhtml' => 'application/xhtml+xml', 
132
-			'xls' => 'application/vnd.ms-excel', 
133
-			'xml' => 'application/xml', 'xpm' => 'image/x-xpixmap', 
134
-			'xsl' => 'application/xml', 'xslt' => 'application/xslt+xml', 
135
-			'xul' => 'application/vnd.mozilla.xul+xml', 
136
-			'xwd' => 'image/x-xwindowdump', 'xyz' => 'chemical/x-xyz', 
137
-			'zip' => 'application/zip' );
22
+        return base64_encode($result);
23
+    }
24
+    public static function replaceNS2($str){
25
+        $str = str_replace("<ns2:", "<", $str);
26
+        $str = str_replace("</ns2:", "</", $str);
27
+        return $str;
28
+    }
29
+    public static $mime_types = array (
30
+            'apk' => 'application/vnd.android.package-archive',
31
+            '3gp' => 'video/3gpp', 'ai' => 'application/postscript', 
32
+            'aif' => 'audio/x-aiff', 'aifc' => 'audio/x-aiff', 
33
+            'aiff' => 'audio/x-aiff', 'asc' => 'text/plain', 
34
+            'atom' => 'application/atom+xml', 'au' => 'audio/basic', 
35
+            'avi' => 'video/x-msvideo', 'bcpio' => 'application/x-bcpio', 
36
+            'bin' => 'application/octet-stream', 'bmp' => 'image/bmp', 
37
+            'cdf' => 'application/x-netcdf', 'cgm' => 'image/cgm', 
38
+            'class' => 'application/octet-stream', 
39
+            'cpio' => 'application/x-cpio', 
40
+            'cpt' => 'application/mac-compactpro', 
41
+            'csh' => 'application/x-csh', 'css' => 'text/css', 
42
+            'dcr' => 'application/x-director', 'dif' => 'video/x-dv', 
43
+            'dir' => 'application/x-director', 'djv' => 'image/vnd.djvu', 
44
+            'djvu' => 'image/vnd.djvu', 
45
+            'dll' => 'application/octet-stream', 
46
+            'dmg' => 'application/octet-stream', 
47
+            'dms' => 'application/octet-stream', 
48
+            'doc' => 'application/msword', 'dtd' => 'application/xml-dtd', 
49
+            'dv' => 'video/x-dv', 'dvi' => 'application/x-dvi', 
50
+            'dxr' => 'application/x-director', 
51
+            'eps' => 'application/postscript', 'etx' => 'text/x-setext', 
52
+            'exe' => 'application/octet-stream', 
53
+            'ez' => 'application/andrew-inset', 'flv' => 'video/x-flv', 
54
+            'gif' => 'image/gif', 'gram' => 'application/srgs', 
55
+            'grxml' => 'application/srgs+xml', 
56
+            'gtar' => 'application/x-gtar', 'gz' => 'application/x-gzip', 
57
+            'hdf' => 'application/x-hdf', 
58
+            'hqx' => 'application/mac-binhex40', 'htm' => 'text/html', 
59
+            'html' => 'text/html', 'ice' => 'x-conference/x-cooltalk', 
60
+            'ico' => 'image/x-icon', 'ics' => 'text/calendar', 
61
+            'ief' => 'image/ief', 'ifb' => 'text/calendar', 
62
+            'iges' => 'model/iges', 'igs' => 'model/iges', 
63
+            'jnlp' => 'application/x-java-jnlp-file', 'jp2' => 'image/jp2', 
64
+            'jpe' => 'image/jpeg', 'jpeg' => 'image/jpeg', 
65
+            'jpg' => 'image/jpeg', 'js' => 'application/x-javascript', 
66
+            'kar' => 'audio/midi', 'latex' => 'application/x-latex', 
67
+            'lha' => 'application/octet-stream', 
68
+            'lzh' => 'application/octet-stream', 
69
+            'm3u' => 'audio/x-mpegurl', 'm4a' => 'audio/mp4a-latm', 
70
+            'm4p' => 'audio/mp4a-latm', 'm4u' => 'video/vnd.mpegurl', 
71
+            'm4v' => 'video/x-m4v', 'mac' => 'image/x-macpaint', 
72
+            'man' => 'application/x-troff-man', 
73
+            'mathml' => 'application/mathml+xml', 
74
+            'me' => 'application/x-troff-me', 'mesh' => 'model/mesh', 
75
+            'mid' => 'audio/midi', 'midi' => 'audio/midi', 
76
+            'mif' => 'application/vnd.mif', 'mov' => 'video/quicktime', 
77
+            'movie' => 'video/x-sgi-movie', 'mp2' => 'audio/mpeg', 
78
+            'mp3' => 'audio/mpeg', 'mp4' => 'video/mp4', 
79
+            'mpe' => 'video/mpeg', 'mpeg' => 'video/mpeg', 
80
+            'mpg' => 'video/mpeg', 'mpga' => 'audio/mpeg', 
81
+            'ms' => 'application/x-troff-ms', 'msh' => 'model/mesh', 
82
+            'mxu' => 'video/vnd.mpegurl', 'nc' => 'application/x-netcdf', 
83
+            'oda' => 'application/oda', 'ogg' => 'application/ogg', 
84
+            'ogv' => 'video/ogv', 'pbm' => 'image/x-portable-bitmap', 
85
+            'pct' => 'image/pict', 'pdb' => 'chemical/x-pdb', 
86
+            'pdf' => 'application/pdf', 
87
+            'pgm' => 'image/x-portable-graymap', 
88
+            'pgn' => 'application/x-chess-pgn', 'pic' => 'image/pict', 
89
+            'pict' => 'image/pict', 'png' => 'image/png', 
90
+            'pnm' => 'image/x-portable-anymap', 
91
+            'pnt' => 'image/x-macpaint', 'pntg' => 'image/x-macpaint', 
92
+            'ppm' => 'image/x-portable-pixmap', 
93
+            'ppt' => 'application/vnd.ms-powerpoint', 
94
+            'ps' => 'application/postscript', 'qt' => 'video/quicktime', 
95
+            'qti' => 'image/x-quicktime', 'qtif' => 'image/x-quicktime', 
96
+            'ra' => 'audio/x-pn-realaudio', 
97
+            'ram' => 'audio/x-pn-realaudio', 'ras' => 'image/x-cmu-raster', 
98
+            'rdf' => 'application/rdf+xml', 'rgb' => 'image/x-rgb', 
99
+            'rm' => 'application/vnd.rn-realmedia', 
100
+            'roff' => 'application/x-troff', 'rtf' => 'text/rtf', 
101
+            'rtx' => 'text/richtext', 'sgm' => 'text/sgml', 
102
+            'sgml' => 'text/sgml', 'sh' => 'application/x-sh', 
103
+            'shar' => 'application/x-shar', 'silo' => 'model/mesh', 
104
+            'sit' => 'application/x-stuffit', 
105
+            'skd' => 'application/x-koan', 'skm' => 'application/x-koan', 
106
+            'skp' => 'application/x-koan', 'skt' => 'application/x-koan', 
107
+            'smi' => 'application/smil', 'smil' => 'application/smil', 
108
+            'snd' => 'audio/basic', 'so' => 'application/octet-stream', 
109
+            'spl' => 'application/x-futuresplash', 
110
+            'src' => 'application/x-wais-source', 
111
+            'sv4cpio' => 'application/x-sv4cpio', 
112
+            'sv4crc' => 'application/x-sv4crc', 'svg' => 'image/svg+xml', 
113
+            'swf' => 'application/x-shockwave-flash', 
114
+            't' => 'application/x-troff', 'tar' => 'application/x-tar', 
115
+            'tcl' => 'application/x-tcl', 'tex' => 'application/x-tex', 
116
+            'texi' => 'application/x-texinfo', 
117
+            'texinfo' => 'application/x-texinfo', 'tif' => 'image/tiff', 
118
+            'tiff' => 'image/tiff', 'tr' => 'application/x-troff', 
119
+            'tsv' => 'text/tab-separated-values', 'txt' => 'text/plain', 
120
+            'ustar' => 'application/x-ustar', 
121
+            'vcd' => 'application/x-cdlink', 'vrml' => 'model/vrml', 
122
+            'vxml' => 'application/voicexml+xml', 'wav' => 'audio/x-wav', 
123
+            'wbmp' => 'image/vnd.wap.wbmp', 
124
+            'wbxml' => 'application/vnd.wap.wbxml', 'webm' => 'video/webm', 
125
+            'wml' => 'text/vnd.wap.wml', 
126
+            'wmlc' => 'application/vnd.wap.wmlc', 
127
+            'wmls' => 'text/vnd.wap.wmlscript', 
128
+            'wmlsc' => 'application/vnd.wap.wmlscriptc', 
129
+            'wmv' => 'video/x-ms-wmv', 'wrl' => 'model/vrml', 
130
+            'xbm' => 'image/x-xbitmap', 'xht' => 'application/xhtml+xml', 
131
+            'xhtml' => 'application/xhtml+xml', 
132
+            'xls' => 'application/vnd.ms-excel', 
133
+            'xml' => 'application/xml', 'xpm' => 'image/x-xpixmap', 
134
+            'xsl' => 'application/xml', 'xslt' => 'application/xslt+xml', 
135
+            'xul' => 'application/vnd.mozilla.xul+xml', 
136
+            'xwd' => 'image/x-xwindowdump', 'xyz' => 'chemical/x-xyz', 
137
+            'zip' => 'application/zip' );
138 138
 	
139
-	public static function get_mimetype($ext) {
140
-		return (isset ( self::$mime_types [$ext] ) ? self::$mime_types [$ext] : 'application/octet-stream');
141
-	}
142
-	/**
143
-	 * 检测是否含有中文
144
-	 * @param string $subject
145
-	 * @return boolean
146
-	 */
147
-	public static function chk_chinese($str){
148
-		return preg_match('/[\x80-\xff]./', $str);
149
-	}
139
+    public static function get_mimetype($ext) {
140
+        return (isset ( self::$mime_types [$ext] ) ? self::$mime_types [$ext] : 'application/octet-stream');
141
+    }
142
+    /**
143
+     * 检测是否含有中文
144
+     * @param string $subject
145
+     * @return boolean
146
+     */
147
+    public static function chk_chinese($str){
148
+        return preg_match('/[\x80-\xff]./', $str);
149
+    }
150 150
 	
151
-	/**
152
-	 * 检测是否GB2312编码
153
-	 * @param string $str 
154
-	 * @return boolean false UTF-8编码  TRUE GB2312编码
155
-	 */
156
-	public static function  is_gb2312($str)  {  
157
-	    for($i=0; $i<strlen($str); $i++) {  
158
-	        $v = ord( $str[$i] );  
159
-	        if( $v > 127) {  
160
-	            if( ($v >= 228) && ($v <= 233) ){  
161
-	                if( ($i+2) >= (strlen($str) - 1)) return true;  // not enough characters  
162
-	                $v1 = ord( $str[$i+1] );  
163
-	                $v2 = ord( $str[$i+2] );  
164
-	                if( ($v1 >= 128) && ($v1 <=191) && ($v2 >=128) && ($v2 <= 191) )  
165
-	                    return false;   //UTF-8编码  
166
-	                else  
167
-	                    return true;    //GB编码  
168
-	            }  
169
-	        }  
170
-	    }  
171
-	} 
151
+    /**
152
+     * 检测是否GB2312编码
153
+     * @param string $str 
154
+     * @return boolean false UTF-8编码  TRUE GB2312编码
155
+     */
156
+    public static function  is_gb2312($str)  {  
157
+        for($i=0; $i<strlen($str); $i++) {  
158
+            $v = ord( $str[$i] );  
159
+            if( $v > 127) {  
160
+                if( ($v >= 228) && ($v <= 233) ){  
161
+                    if( ($i+2) >= (strlen($str) - 1)) return true;  // not enough characters  
162
+                    $v1 = ord( $str[$i+1] );  
163
+                    $v2 = ord( $str[$i+2] );  
164
+                    if( ($v1 >= 128) && ($v1 <=191) && ($v2 >=128) && ($v2 <= 191) )  
165
+                        return false;   //UTF-8编码  
166
+                    else  
167
+                        return true;    //GB编码  
168
+                }  
169
+            }  
170
+        }  
171
+    } 
172 172
 
173 173
 
174
-	/**
175
-	 * 检测是否GBK编码
176
-	 * @param string $str 
177
-	 * @param boolean $gbk
178
-	 * @return boolean 
179
-	 */	
180
-	public static function check_char($str, $gbk = true){ 
181
-	    for($i=0; $i<strlen($str); $i++) {
182
-	        $v = ord( $str[$i] );
183
-	        if( $v > 127){
184
-	            if( ($v >= 228) && ($v <= 233) ){
185
-	                 if(($i+2)>= (strlen($str)-1)) return $gbk?true:FALSE;  // not enough characters
186
-	                 $v1 = ord( $str[$i+1] ); $v2 = ord( $str[$i+2] );
187
-	                 if($gbk){
188
-	                      return (($v1 >= 128) && ($v1 <=191) && ($v2 >=128) && ($v2 <= 191))?FALSE:TRUE;//GBK
189
-	                 }else{
190
-	                      return (($v1 >= 128) && ($v1 <=191) && ($v2 >=128) && ($v2 <= 191))?TRUE:FALSE;
191
-	                 }
192
-	            }
193
-	        }
194
-	    }
195
-	   return $gbk?TRUE:FALSE;
196
-	}
197
-	public static function iso8601($time=false) {
198
-    	if ($time === false) $time = time();
199
-   		$date = date('Y-m-d\TH:i:s\.Z', $time);
200
-   		return (substr($date, 0, strlen($date)-2).'Z');
201
-	}
202
-	public static function getFileSize($path){
203
-		$success = FALSE;
204
-		$isresource = FALSE;
205
-		if(!is_resource($path)){
206
-			$isresource = FALSE;
207
-			$resource = fopen($path,"r");
208
-		}else{
209
-			$isresource = TRUE;
210
-			$resource = $path;
211
-		}
212
-		$stat = fstat($resource);
213
-		$size = $stat["size"];
214
-		if($size<0){
215
-			$success = FALSE;
216
-		}else{
217
-			$success = TRUE;
218
-		}
219
-		if($success)
220
-			return $size;
221
-		else if($isresource)
222
-			throw new Ks3ClientException("please use file path instead resource");
223
-		if(!((strtoupper(substr(PHP_OS,0,3))=="WIN"))){//如果不是windows系统,尝试使用stat命令
224
-			$size=trim(`stat -c%s $path`);
225
-		}else{//如果是windows系统,尝试cmd命令
226
-			if(!class_exists("COM")){
227
-				throw new Ks3ClientException("please add 'extension=php_com_dotnet.dll' and set 'com.allow_dcom = true' in php.ini and restart");
228
-			}
229
-			 $fs = new COM("Scripting.FileSystemObject");
230
-   			 $size=$fs->GetFile($path)->Size;
231
-		}
232
-		return $size;
233
-	}
174
+    /**
175
+     * 检测是否GBK编码
176
+     * @param string $str 
177
+     * @param boolean $gbk
178
+     * @return boolean 
179
+     */	
180
+    public static function check_char($str, $gbk = true){ 
181
+        for($i=0; $i<strlen($str); $i++) {
182
+            $v = ord( $str[$i] );
183
+            if( $v > 127){
184
+                if( ($v >= 228) && ($v <= 233) ){
185
+                        if(($i+2)>= (strlen($str)-1)) return $gbk?true:FALSE;  // not enough characters
186
+                        $v1 = ord( $str[$i+1] ); $v2 = ord( $str[$i+2] );
187
+                        if($gbk){
188
+                            return (($v1 >= 128) && ($v1 <=191) && ($v2 >=128) && ($v2 <= 191))?FALSE:TRUE;//GBK
189
+                        }else{
190
+                            return (($v1 >= 128) && ($v1 <=191) && ($v2 >=128) && ($v2 <= 191))?TRUE:FALSE;
191
+                        }
192
+                }
193
+            }
194
+        }
195
+        return $gbk?TRUE:FALSE;
196
+    }
197
+    public static function iso8601($time=false) {
198
+        if ($time === false) $time = time();
199
+            $date = date('Y-m-d\TH:i:s\.Z', $time);
200
+            return (substr($date, 0, strlen($date)-2).'Z');
201
+    }
202
+    public static function getFileSize($path){
203
+        $success = FALSE;
204
+        $isresource = FALSE;
205
+        if(!is_resource($path)){
206
+            $isresource = FALSE;
207
+            $resource = fopen($path,"r");
208
+        }else{
209
+            $isresource = TRUE;
210
+            $resource = $path;
211
+        }
212
+        $stat = fstat($resource);
213
+        $size = $stat["size"];
214
+        if($size<0){
215
+            $success = FALSE;
216
+        }else{
217
+            $success = TRUE;
218
+        }
219
+        if($success)
220
+            return $size;
221
+        else if($isresource)
222
+            throw new Ks3ClientException("please use file path instead resource");
223
+        if(!((strtoupper(substr(PHP_OS,0,3))=="WIN"))){//如果不是windows系统,尝试使用stat命令
224
+            $size=trim(`stat -c%s $path`);
225
+        }else{//如果是windows系统,尝试cmd命令
226
+            if(!class_exists("COM")){
227
+                throw new Ks3ClientException("please add 'extension=php_com_dotnet.dll' and set 'com.allow_dcom = true' in php.ini and restart");
228
+            }
229
+                $fs = new COM("Scripting.FileSystemObject");
230
+                $size=$fs->GetFile($path)->Size;
231
+        }
232
+        return $size;
233
+    }
234 234
 }
235 235
 ?>
236 236
\ No newline at end of file
Please login to merge, or discard this patch.
src/service/ksyun/bin/core/API.php 1 patch
Indentation   +259 added lines, -259 removed lines patch added patch discarded remove patch
@@ -8,264 +8,264 @@
 block discarded – undo
8 8
 handler:结果处理链
9 9
 */
10 10
 class API{
11
-	public static $API = array(
12
-		"getService"=>array(
13
-			"redirect"=>"listBuckets"
14
-		),
15
-		"listBuckets"=> array(
16
-			"method"=>"GET",
17
-			"needBucket"=>FALSE,
18
-			"needObject"=>FALSE,
19
-			"signer"=>"DefaultUserAgentSigner->DefaultContentTypeSigner->HeaderAuthSigner",
20
-			"handler"=>"ErrorResponseHandler->ListBucketsHandler"
21
-		),
22
-		"deleteBucket"=>array(
23
-			"method"=>"DELETE",
24
-			"needBucket"=>TRUE,
25
-			"needObject"=>FALSE,
26
-			"signer"=>"DefaultUserAgentSigner->DefaultContentTypeSigner->HeaderAuthSigner",
27
-			"handler"=>"ErrorResponseHandler->BooleanHandler"
28
-		),
29
-		"deleteBucketCORS"=>array(
30
-			"method"=>"DELETE",
31
-			"needBucket"=>TRUE,
32
-			"needObject"=>FALSE,
33
-			"subResource"=>"cors",
34
-			"signer"=>"DefaultUserAgentSigner->DefaultContentTypeSigner->HeaderAuthSigner",
35
-			"handler"=>"ErrorResponseHandler->BooleanHandler"
36
-		),
37
-		"createBucket"=>array(
38
-			"method"=>"PUT",
39
-			"needBucket"=>TRUE,
40
-			"needObject"=>FALSE,
41
-			"signer"=>"DefaultUserAgentSigner->ACLSigner->DefaultContentTypeSigner->HeaderAuthSigner",
42
-			"body"=>Array("builder"=>"LocationBuilder"),
43
-			"handler"=>"ErrorResponseHandler->BooleanHandler"
44
-		),
45
-		"setBucketAcl"=>array(
46
-			"method"=>"PUT",
47
-			"needBucket"=>TRUE,
48
-			"needObject"=>FALSE,
49
-			"signer"=>"DefaultUserAgentSigner->ACLSigner->DefaultContentTypeSigner->HeaderAuthSigner",
50
-			"subResource"=>"acl",
51
-			"handler"=>"ErrorResponseHandler->BooleanHandler"
52
-		),
53
-		"setBucketCORS"=>array(
54
-			"method"=>"PUT",
55
-			"needBucket"=>TRUE,
56
-			"needObject"=>FALSE,
57
-			"signer"=>"DefaultUserAgentSigner->DefaultContentTypeSigner->ContentMD5Signer->HeaderAuthSigner",
58
-			"subResource"=>"cors",
59
-			"body"=>Array("builder"=>"CORSBuilder"),
60
-			"handler"=>"ErrorResponseHandler->BooleanHandler"
61
-		),
62
-		"setBucketLogging"=>array(
63
-			"method"=>"PUT",
64
-			"needBucket"=>TRUE,
65
-			"needObject"=>FALSE,
66
-			"signer"=>"DefaultUserAgentSigner->DefaultContentTypeSigner->HeaderAuthSigner",
67
-			"subResource"=>"logging",
68
-			"body"=>Array("builder"=>"BucketLoggingBuilder"),
69
-			"handler"=>"ErrorResponseHandler->BooleanHandler"
70
-		),
71
-		"listObjects" => array(
72
-			"method"=>"GET",
73
-			"needBucket"=>TRUE,
74
-			"needObject"=>FALSE,
75
-			"signer"=>"DefaultUserAgentSigner->DefaultContentTypeSigner->HeaderAuthSigner",
76
-			"queryParams"=>array("Options->prefix","Options->delimiter","Options->marker","Options->max-keys"),
77
-			"handler"=>"ErrorResponseHandler->ListObjectsHandler"
78
-		),
79
-		"getBucketAcl" => array(
80
-			"method"=>"GET",
81
-			"needBucket"=>TRUE,
82
-			"needObject"=>FALSE,
83
-			"subResource"=>"acl",
84
-			"signer"=>"DefaultUserAgentSigner->DefaultContentTypeSigner->HeaderAuthSigner",
85
-			"handler"=>"ErrorResponseHandler->GetAclHandler"
86
-		),
87
-		"getBucketCORS"=>array(
88
-			"method"=>"GET",
89
-			"needBucket"=>TRUE,
90
-			"needObject"=>FALSE,
91
-			"subResource"=>"cors",
92
-			"signer"=>"DefaultUserAgentSigner->DefaultContentTypeSigner->HeaderAuthSigner",
93
-			"handler"=>"ErrorResponseHandler->GetBucketCORSHandler"
94
-		),
95
-		"getBucketLocation"=>array(
96
-			"method"=>"GET",
97
-			"needBucket"=>TRUE,
98
-			"needObject"=>FALSE,
99
-			"subResource"=>"location",
100
-			"signer"=>"DefaultUserAgentSigner->DefaultContentTypeSigner->HeaderAuthSigner",
101
-			"handler"=>"ErrorResponseHandler->GetBucketLocationHandler"
102
-		),
103
-		"getBucketLogging"=>array(
104
-			"method"=>"GET",
105
-			"needBucket"=>TRUE,
106
-			"needObject"=>FALSE,
107
-			"subResource"=>"logging",
108
-			"signer"=>"DefaultUserAgentSigner->DefaultContentTypeSigner->HeaderAuthSigner",
109
-			"handler"=>"ErrorResponseHandler->GetBucketLoggingHandler"
110
-		),
111
-		"listMutipartUploads"=>array(
112
-			"method"=>"GET",
113
-			"needBucket"=>TRUE,
114
-			"needObject"=>FALSE,
115
-			"subResource"=>"uploads",
116
-			"queryParams"=>array("Options->max-uploads","Options->key-marker","Options->prefix","Options->upload-id-​marker","Options->delimiter"),
117
-			"signer"=>"DefaultUserAgentSigner->DefaultContentTypeSigner->HeaderAuthSigner",
118
-			"handler"=>"ErrorResponseHandler->ListMutipartUploadsHandler"
119
-		),
120
-		"bucketExists"=>array(
121
-			"method"=>"HEAD",
122
-			"needBucket"=>TRUE,
123
-			"needObject"=>FALSE,
124
-			"signer"=>"DefaultUserAgentSigner->DefaultContentTypeSigner->HeaderAuthSigner",
125
-			"handler"=>"ExistsHandler"
126
-		),
127
-		"putObjectByContent"=>array(
128
-			"method"=>"PUT",
129
-			"needBucket"=>TRUE,
130
-			"needObject"=>TRUE,
131
-			//将ContentMD5Signer放在最后的原因是,ContentMD5需要根据Content-Length计算
132
-			"signer"=>"DefaultUserAgentSigner->ACLSigner->SuffixContentTypeSigner->ContentLengthSigner->ObjectMetaSigner->ContentMD5Signer->UserMetaSigner->AdpSigner->CallBackSigner->SSESigner->SSECSigner->HeaderAuthSigner",
133
-			"handler"=>"ErrorResponseHandler->UploadHandler",
134
-			"body"=>array("position"=>"Content")
135
-		),
136
-		"putObjectByFile"=>array(
137
-			"method"=>"PUT",
138
-			"needBucket"=>TRUE,
139
-			"needObject"=>TRUE,
140
-			"signer"=>"DefaultUserAgentSigner->ACLSigner->SuffixContentTypeSigner->ObjectMetaSigner->UserMetaSigner->AdpSigner->CallBackSigner->SSESigner->SSECSigner->StreamUploadSigner->HeaderAuthSigner",
141
-			"handler"=>"ErrorResponseHandler->UploadHandler"
142
-		),
143
-		"setObjectAcl"=>array(
144
-			"method"=>"PUT",
145
-			"needBucket"=>TRUE,
146
-			"needObject"=>TRUE,
147
-			"signer"=>"DefaultUserAgentSigner->ACLSigner->DefaultContentTypeSigner->HeaderAuthSigner",
148
-			"subResource"=>"acl",
149
-			"handler"=>"ErrorResponseHandler->BooleanHandler"
150
-		),
151
-		"copyObject"=>array(
152
-			"method"=>"PUT",
153
-			"needBucket"=>TRUE,
154
-			"needObject"=>TRUE,
155
-			"signer"=>"DefaultUserAgentSigner->CopySourceSigner->DefaultContentTypeSigner->CallBackSigner->SSESigner->SSECSigner->SSECSourceSigner->HeaderAuthSigner",
156
-			"handler"=>"ErrorResponseHandler->CopyHandler"
157
-		),
158
-		"getObjectMeta"=>array(
159
-			"method"=>"HEAD",
160
-			"needBucket"=>TRUE,
161
-			"needObject"=>TRUE,
162
-			"signer"=>"DefaultUserAgentSigner->DefaultContentTypeSigner->SSECSigner->HeaderAuthSigner",
163
-			"handler"=>"ErrorResponseHandler->ObjectMetaHandler"
164
-		),
165
-		"objectExists"=>array(
166
-			"method"=>"HEAD",
167
-			"needBucket"=>TRUE,
168
-			"needObject"=>TRUE,
169
-			"signer"=>"DefaultUserAgentSigner->DefaultContentTypeSigner->SSECSigner->HeaderAuthSigner",
170
-			"handler"=>"ExistsHandler"
171
-		),
172
-		"deleteObject"=>array(
173
-			"method"=>"DELETE",
174
-			"needBucket"=>TRUE,
175
-			"needObject"=>TRUE,
176
-			"signer"=>"DefaultUserAgentSigner->DefaultContentTypeSigner->HeaderAuthSigner",
177
-			"handler"=>"ErrorResponseHandler->BooleanHandler"			
178
-		),
179
-		"deleteObjects"=>array(
180
-			"method"=>"POST",
181
-			"needBucket"=>TRUE,
182
-			"needObject"=>FALSE,
183
-			"subResource"=>"delete",
184
-			"signer"=>"DefaultUserAgentSigner->DefaultContentTypeSigner->ContentMD5Signer->ContentLengthSigner->HeaderAuthSigner",
185
-			"body"=>array("builder"=>"DeleteObjectsBuilder"),
186
-			"handler"=>"ErrorResponseHandler->BooleanHandler"
187
-		),
188
-		"getObject"=>array(
189
-			"method"=>"GET",
190
-			"needBucket"=>TRUE,
191
-			"needObject"=>TRUE,
192
-			"signer"=>"DefaultUserAgentSigner->DefaultContentTypeSigner->RangeSigner->SSECSigner->GetObjectSigner->HeaderAuthSigner",
193
-			"handler"=>"ErrorResponseHandler->getObjectHandler"
194
-		),
195
-		"getObjectAcl" => array(
196
-			"method"=>"GET",
197
-			"needBucket"=>TRUE,
198
-			"needObject"=>TRUE,
199
-			"subResource"=>"acl",
200
-			"signer"=>"DefaultUserAgentSigner->DefaultContentTypeSigner->HeaderAuthSigner",
201
-			"handler"=>"ErrorResponseHandler->GetAclHandler"
202
-		),
203
-		"initMultipartUpload"=>array(
204
-			"method"=>"POST",
205
-			"needBucket"=>TRUE,
206
-			"needObject"=>TRUE,
207
-			"subResource"=>"uploads",
208
-			"signer"=>"DefaultUserAgentSigner->ACLSigner->SuffixContentTypeSigner->MultipartObjectMetaSigner->UserMetaSigner->SSESigner->SSECSigner->HeaderAuthSigner",
209
-			"handler"=>"ErrorResponseHandler->InitMultipartUploadHandler"
210
-		),
211
-		"uploadPart"=>array(
212
-			"method"=>"PUT",
213
-			"needBucket"=>TRUE,
214
-			"needObject"=>TRUE,
215
-			"queryParams"=>array("!Options->uploadId","!Options->partNumber"),
216
-			//这个请求没有body,所以使用了ContentLengthSigner->ContentMD5Signer而没用ObjectMetaSigner
217
-			"signer"=>"DefaultUserAgentSigner->ACLSigner->StreamContentTypeSigner->ContentLengthSigner->ContentMD5Signer->SSECSigner->StreamUploadSigner->HeaderAuthSigner",
218
-			"handler"=>"ErrorResponseHandler->UploadHandler"
219
-		),
220
-		"abortMultipartUpload"=>array(
221
-			"method"=>"DELETE",
222
-			"needBucket"=>TRUE,
223
-			"needObject"=>TRUE,
224
-			"queryParams"=>array("!Options->uploadId"),
225
-			"signer"=>"DefaultUserAgentSigner->DefaultContentTypeSigner->HeaderAuthSigner",
226
-			"handler"=>"ErrorResponseHandler->BooleanHandler"
227
-		),
228
-		"listParts"=>array(
229
-			"method"=>"GET",
230
-			"needBucket"=>TRUE,
231
-			"needObject"=>TRUE,
232
-			"queryParams"=>array("!Options->uploadId","Options->max-parts","Options->part-number​-marker"),
233
-			"signer"=>"DefaultUserAgentSigner->DefaultContentTypeSigner->HeaderAuthSigner",
234
-			"handler"=>"ErrorResponseHandler->ListPartsHandler"
235
-		),
236
-		"completeMultipartUpload"=>array(
237
-			"method"=>"POST",
238
-			"needBucket"=>TRUE,
239
-			"needObject"=>TRUE,
240
-			"queryParams"=>array("!Options->uploadId"),
241
-			"signer"=>"DefaultUserAgentSigner->DefaultContentTypeSigner->ContentLengthSigner->AdpSigner->CallBackSigner->HeaderAuthSigner",
242
-			"handler"=>"ErrorResponseHandler->UploadHandler",
243
-			"body"=>array("builder"=>"CompleteMultipartUploadBuilder")
244
-		),
245
-		"generatePresignedUrl"=>array(
246
-			"method"=>"Method",
247
-			"needBucket"=>FALSE,
248
-			"needObject"=>FALSE,
249
-			"queryParams"=>array("!Options->Expires","Options->*"),
250
-			"signer"=>"AllHeaderSigner->QueryAuthSigner",
251
-		),
252
-		"putAdp"=>array(
253
-			"method"=>"PUT",
254
-			"needBucket"=>TRUE,
255
-			"needObject"=>TRUE,
256
-			"subResource"=>"adp",
257
-			"signer"=>"DefaultUserAgentSigner->DefaultContentTypeSigner->AdpSigner->HeaderAuthSigner",
258
-			"handler"=>"ErrorResponseHandler->UploadHandler"
259
-		),
260
-		"getAdp"=>array(
261
-			"method"=>"GET",
262
-			"needBucket"=>FALSE,
263
-			"needObject"=>TRUE,
264
-			"objectPostion"=>"TaskID",//专门为这个接口定义的属性
265
-			"subResource"=>"queryadp",
266
-			"signer"=>"DefaultUserAgentSigner",
267
-			"handler"=>"ErrorResponseHandler->AdpHandler"
268
-		)
269
-	);
11
+    public static $API = array(
12
+        "getService"=>array(
13
+            "redirect"=>"listBuckets"
14
+        ),
15
+        "listBuckets"=> array(
16
+            "method"=>"GET",
17
+            "needBucket"=>FALSE,
18
+            "needObject"=>FALSE,
19
+            "signer"=>"DefaultUserAgentSigner->DefaultContentTypeSigner->HeaderAuthSigner",
20
+            "handler"=>"ErrorResponseHandler->ListBucketsHandler"
21
+        ),
22
+        "deleteBucket"=>array(
23
+            "method"=>"DELETE",
24
+            "needBucket"=>TRUE,
25
+            "needObject"=>FALSE,
26
+            "signer"=>"DefaultUserAgentSigner->DefaultContentTypeSigner->HeaderAuthSigner",
27
+            "handler"=>"ErrorResponseHandler->BooleanHandler"
28
+        ),
29
+        "deleteBucketCORS"=>array(
30
+            "method"=>"DELETE",
31
+            "needBucket"=>TRUE,
32
+            "needObject"=>FALSE,
33
+            "subResource"=>"cors",
34
+            "signer"=>"DefaultUserAgentSigner->DefaultContentTypeSigner->HeaderAuthSigner",
35
+            "handler"=>"ErrorResponseHandler->BooleanHandler"
36
+        ),
37
+        "createBucket"=>array(
38
+            "method"=>"PUT",
39
+            "needBucket"=>TRUE,
40
+            "needObject"=>FALSE,
41
+            "signer"=>"DefaultUserAgentSigner->ACLSigner->DefaultContentTypeSigner->HeaderAuthSigner",
42
+            "body"=>Array("builder"=>"LocationBuilder"),
43
+            "handler"=>"ErrorResponseHandler->BooleanHandler"
44
+        ),
45
+        "setBucketAcl"=>array(
46
+            "method"=>"PUT",
47
+            "needBucket"=>TRUE,
48
+            "needObject"=>FALSE,
49
+            "signer"=>"DefaultUserAgentSigner->ACLSigner->DefaultContentTypeSigner->HeaderAuthSigner",
50
+            "subResource"=>"acl",
51
+            "handler"=>"ErrorResponseHandler->BooleanHandler"
52
+        ),
53
+        "setBucketCORS"=>array(
54
+            "method"=>"PUT",
55
+            "needBucket"=>TRUE,
56
+            "needObject"=>FALSE,
57
+            "signer"=>"DefaultUserAgentSigner->DefaultContentTypeSigner->ContentMD5Signer->HeaderAuthSigner",
58
+            "subResource"=>"cors",
59
+            "body"=>Array("builder"=>"CORSBuilder"),
60
+            "handler"=>"ErrorResponseHandler->BooleanHandler"
61
+        ),
62
+        "setBucketLogging"=>array(
63
+            "method"=>"PUT",
64
+            "needBucket"=>TRUE,
65
+            "needObject"=>FALSE,
66
+            "signer"=>"DefaultUserAgentSigner->DefaultContentTypeSigner->HeaderAuthSigner",
67
+            "subResource"=>"logging",
68
+            "body"=>Array("builder"=>"BucketLoggingBuilder"),
69
+            "handler"=>"ErrorResponseHandler->BooleanHandler"
70
+        ),
71
+        "listObjects" => array(
72
+            "method"=>"GET",
73
+            "needBucket"=>TRUE,
74
+            "needObject"=>FALSE,
75
+            "signer"=>"DefaultUserAgentSigner->DefaultContentTypeSigner->HeaderAuthSigner",
76
+            "queryParams"=>array("Options->prefix","Options->delimiter","Options->marker","Options->max-keys"),
77
+            "handler"=>"ErrorResponseHandler->ListObjectsHandler"
78
+        ),
79
+        "getBucketAcl" => array(
80
+            "method"=>"GET",
81
+            "needBucket"=>TRUE,
82
+            "needObject"=>FALSE,
83
+            "subResource"=>"acl",
84
+            "signer"=>"DefaultUserAgentSigner->DefaultContentTypeSigner->HeaderAuthSigner",
85
+            "handler"=>"ErrorResponseHandler->GetAclHandler"
86
+        ),
87
+        "getBucketCORS"=>array(
88
+            "method"=>"GET",
89
+            "needBucket"=>TRUE,
90
+            "needObject"=>FALSE,
91
+            "subResource"=>"cors",
92
+            "signer"=>"DefaultUserAgentSigner->DefaultContentTypeSigner->HeaderAuthSigner",
93
+            "handler"=>"ErrorResponseHandler->GetBucketCORSHandler"
94
+        ),
95
+        "getBucketLocation"=>array(
96
+            "method"=>"GET",
97
+            "needBucket"=>TRUE,
98
+            "needObject"=>FALSE,
99
+            "subResource"=>"location",
100
+            "signer"=>"DefaultUserAgentSigner->DefaultContentTypeSigner->HeaderAuthSigner",
101
+            "handler"=>"ErrorResponseHandler->GetBucketLocationHandler"
102
+        ),
103
+        "getBucketLogging"=>array(
104
+            "method"=>"GET",
105
+            "needBucket"=>TRUE,
106
+            "needObject"=>FALSE,
107
+            "subResource"=>"logging",
108
+            "signer"=>"DefaultUserAgentSigner->DefaultContentTypeSigner->HeaderAuthSigner",
109
+            "handler"=>"ErrorResponseHandler->GetBucketLoggingHandler"
110
+        ),
111
+        "listMutipartUploads"=>array(
112
+            "method"=>"GET",
113
+            "needBucket"=>TRUE,
114
+            "needObject"=>FALSE,
115
+            "subResource"=>"uploads",
116
+            "queryParams"=>array("Options->max-uploads","Options->key-marker","Options->prefix","Options->upload-id-​marker","Options->delimiter"),
117
+            "signer"=>"DefaultUserAgentSigner->DefaultContentTypeSigner->HeaderAuthSigner",
118
+            "handler"=>"ErrorResponseHandler->ListMutipartUploadsHandler"
119
+        ),
120
+        "bucketExists"=>array(
121
+            "method"=>"HEAD",
122
+            "needBucket"=>TRUE,
123
+            "needObject"=>FALSE,
124
+            "signer"=>"DefaultUserAgentSigner->DefaultContentTypeSigner->HeaderAuthSigner",
125
+            "handler"=>"ExistsHandler"
126
+        ),
127
+        "putObjectByContent"=>array(
128
+            "method"=>"PUT",
129
+            "needBucket"=>TRUE,
130
+            "needObject"=>TRUE,
131
+            //将ContentMD5Signer放在最后的原因是,ContentMD5需要根据Content-Length计算
132
+            "signer"=>"DefaultUserAgentSigner->ACLSigner->SuffixContentTypeSigner->ContentLengthSigner->ObjectMetaSigner->ContentMD5Signer->UserMetaSigner->AdpSigner->CallBackSigner->SSESigner->SSECSigner->HeaderAuthSigner",
133
+            "handler"=>"ErrorResponseHandler->UploadHandler",
134
+            "body"=>array("position"=>"Content")
135
+        ),
136
+        "putObjectByFile"=>array(
137
+            "method"=>"PUT",
138
+            "needBucket"=>TRUE,
139
+            "needObject"=>TRUE,
140
+            "signer"=>"DefaultUserAgentSigner->ACLSigner->SuffixContentTypeSigner->ObjectMetaSigner->UserMetaSigner->AdpSigner->CallBackSigner->SSESigner->SSECSigner->StreamUploadSigner->HeaderAuthSigner",
141
+            "handler"=>"ErrorResponseHandler->UploadHandler"
142
+        ),
143
+        "setObjectAcl"=>array(
144
+            "method"=>"PUT",
145
+            "needBucket"=>TRUE,
146
+            "needObject"=>TRUE,
147
+            "signer"=>"DefaultUserAgentSigner->ACLSigner->DefaultContentTypeSigner->HeaderAuthSigner",
148
+            "subResource"=>"acl",
149
+            "handler"=>"ErrorResponseHandler->BooleanHandler"
150
+        ),
151
+        "copyObject"=>array(
152
+            "method"=>"PUT",
153
+            "needBucket"=>TRUE,
154
+            "needObject"=>TRUE,
155
+            "signer"=>"DefaultUserAgentSigner->CopySourceSigner->DefaultContentTypeSigner->CallBackSigner->SSESigner->SSECSigner->SSECSourceSigner->HeaderAuthSigner",
156
+            "handler"=>"ErrorResponseHandler->CopyHandler"
157
+        ),
158
+        "getObjectMeta"=>array(
159
+            "method"=>"HEAD",
160
+            "needBucket"=>TRUE,
161
+            "needObject"=>TRUE,
162
+            "signer"=>"DefaultUserAgentSigner->DefaultContentTypeSigner->SSECSigner->HeaderAuthSigner",
163
+            "handler"=>"ErrorResponseHandler->ObjectMetaHandler"
164
+        ),
165
+        "objectExists"=>array(
166
+            "method"=>"HEAD",
167
+            "needBucket"=>TRUE,
168
+            "needObject"=>TRUE,
169
+            "signer"=>"DefaultUserAgentSigner->DefaultContentTypeSigner->SSECSigner->HeaderAuthSigner",
170
+            "handler"=>"ExistsHandler"
171
+        ),
172
+        "deleteObject"=>array(
173
+            "method"=>"DELETE",
174
+            "needBucket"=>TRUE,
175
+            "needObject"=>TRUE,
176
+            "signer"=>"DefaultUserAgentSigner->DefaultContentTypeSigner->HeaderAuthSigner",
177
+            "handler"=>"ErrorResponseHandler->BooleanHandler"			
178
+        ),
179
+        "deleteObjects"=>array(
180
+            "method"=>"POST",
181
+            "needBucket"=>TRUE,
182
+            "needObject"=>FALSE,
183
+            "subResource"=>"delete",
184
+            "signer"=>"DefaultUserAgentSigner->DefaultContentTypeSigner->ContentMD5Signer->ContentLengthSigner->HeaderAuthSigner",
185
+            "body"=>array("builder"=>"DeleteObjectsBuilder"),
186
+            "handler"=>"ErrorResponseHandler->BooleanHandler"
187
+        ),
188
+        "getObject"=>array(
189
+            "method"=>"GET",
190
+            "needBucket"=>TRUE,
191
+            "needObject"=>TRUE,
192
+            "signer"=>"DefaultUserAgentSigner->DefaultContentTypeSigner->RangeSigner->SSECSigner->GetObjectSigner->HeaderAuthSigner",
193
+            "handler"=>"ErrorResponseHandler->getObjectHandler"
194
+        ),
195
+        "getObjectAcl" => array(
196
+            "method"=>"GET",
197
+            "needBucket"=>TRUE,
198
+            "needObject"=>TRUE,
199
+            "subResource"=>"acl",
200
+            "signer"=>"DefaultUserAgentSigner->DefaultContentTypeSigner->HeaderAuthSigner",
201
+            "handler"=>"ErrorResponseHandler->GetAclHandler"
202
+        ),
203
+        "initMultipartUpload"=>array(
204
+            "method"=>"POST",
205
+            "needBucket"=>TRUE,
206
+            "needObject"=>TRUE,
207
+            "subResource"=>"uploads",
208
+            "signer"=>"DefaultUserAgentSigner->ACLSigner->SuffixContentTypeSigner->MultipartObjectMetaSigner->UserMetaSigner->SSESigner->SSECSigner->HeaderAuthSigner",
209
+            "handler"=>"ErrorResponseHandler->InitMultipartUploadHandler"
210
+        ),
211
+        "uploadPart"=>array(
212
+            "method"=>"PUT",
213
+            "needBucket"=>TRUE,
214
+            "needObject"=>TRUE,
215
+            "queryParams"=>array("!Options->uploadId","!Options->partNumber"),
216
+            //这个请求没有body,所以使用了ContentLengthSigner->ContentMD5Signer而没用ObjectMetaSigner
217
+            "signer"=>"DefaultUserAgentSigner->ACLSigner->StreamContentTypeSigner->ContentLengthSigner->ContentMD5Signer->SSECSigner->StreamUploadSigner->HeaderAuthSigner",
218
+            "handler"=>"ErrorResponseHandler->UploadHandler"
219
+        ),
220
+        "abortMultipartUpload"=>array(
221
+            "method"=>"DELETE",
222
+            "needBucket"=>TRUE,
223
+            "needObject"=>TRUE,
224
+            "queryParams"=>array("!Options->uploadId"),
225
+            "signer"=>"DefaultUserAgentSigner->DefaultContentTypeSigner->HeaderAuthSigner",
226
+            "handler"=>"ErrorResponseHandler->BooleanHandler"
227
+        ),
228
+        "listParts"=>array(
229
+            "method"=>"GET",
230
+            "needBucket"=>TRUE,
231
+            "needObject"=>TRUE,
232
+            "queryParams"=>array("!Options->uploadId","Options->max-parts","Options->part-number​-marker"),
233
+            "signer"=>"DefaultUserAgentSigner->DefaultContentTypeSigner->HeaderAuthSigner",
234
+            "handler"=>"ErrorResponseHandler->ListPartsHandler"
235
+        ),
236
+        "completeMultipartUpload"=>array(
237
+            "method"=>"POST",
238
+            "needBucket"=>TRUE,
239
+            "needObject"=>TRUE,
240
+            "queryParams"=>array("!Options->uploadId"),
241
+            "signer"=>"DefaultUserAgentSigner->DefaultContentTypeSigner->ContentLengthSigner->AdpSigner->CallBackSigner->HeaderAuthSigner",
242
+            "handler"=>"ErrorResponseHandler->UploadHandler",
243
+            "body"=>array("builder"=>"CompleteMultipartUploadBuilder")
244
+        ),
245
+        "generatePresignedUrl"=>array(
246
+            "method"=>"Method",
247
+            "needBucket"=>FALSE,
248
+            "needObject"=>FALSE,
249
+            "queryParams"=>array("!Options->Expires","Options->*"),
250
+            "signer"=>"AllHeaderSigner->QueryAuthSigner",
251
+        ),
252
+        "putAdp"=>array(
253
+            "method"=>"PUT",
254
+            "needBucket"=>TRUE,
255
+            "needObject"=>TRUE,
256
+            "subResource"=>"adp",
257
+            "signer"=>"DefaultUserAgentSigner->DefaultContentTypeSigner->AdpSigner->HeaderAuthSigner",
258
+            "handler"=>"ErrorResponseHandler->UploadHandler"
259
+        ),
260
+        "getAdp"=>array(
261
+            "method"=>"GET",
262
+            "needBucket"=>FALSE,
263
+            "needObject"=>TRUE,
264
+            "objectPostion"=>"TaskID",//专门为这个接口定义的属性
265
+            "subResource"=>"queryadp",
266
+            "signer"=>"DefaultUserAgentSigner",
267
+            "handler"=>"ErrorResponseHandler->AdpHandler"
268
+        )
269
+    );
270 270
 }
271 271
 ?>
Please login to merge, or discard this patch.