@@ -28,7 +28,7 @@ discard block |
||
28 | 28 | { |
29 | 29 | if (Pregs::isLink($url)) { |
30 | 30 | $this->url = $url; |
31 | - } else { |
|
31 | + }else { |
|
32 | 32 | preg_match_all('#\bhttps?://[^,\s()<>]+(?:\([\w\d]+\)|([^,[:punct:]\s]|/))#', $url, $match); |
33 | 33 | $this->url = $match[0][0]; |
34 | 34 | } |
@@ -90,17 +90,17 @@ discard block |
||
90 | 90 | 'Connection' => 'keep-alive', |
91 | 91 | 'User-Agent' => 'Mozilla/5.0 (iPhone; CPU iPhone OS 12_1_4 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/16D57 Version/12.0 Safari/604.1' |
92 | 92 | ]; |
93 | - $client = new Client(['timeout' => 2, 'headers' => $headers, 'http_errors' => false,]); |
|
93 | + $client = new Client(['timeout' => 2, 'headers' => $headers, 'http_errors' => false, ]); |
|
94 | 94 | $data = []; |
95 | 95 | if ($headers) { |
96 | 96 | $data['headers'] = $headers; |
97 | 97 | } |
98 | - $data['verify'] = __DIR__ . DIRECTORY_SEPARATOR . 'cacert.pem'; |
|
98 | + $data['verify'] = __DIR__.DIRECTORY_SEPARATOR.'cacert.pem'; |
|
99 | 99 | $jar = new CookieJar; |
100 | 100 | $data['cookies'] = $jar; |
101 | 101 | if (!$params) { |
102 | 102 | $response = $client->request('GET', $url, $data); |
103 | - } else { |
|
103 | + }else { |
|
104 | 104 | $data ['form_params'] = $params; |
105 | 105 | $response = $client->request('POST', $url, $data); |
106 | 106 | } |
@@ -5,31 +5,31 @@ discard block |
||
5 | 5 | |
6 | 6 | //检测API路径 |
7 | 7 | if (!defined("KS3_API_PATH")) { |
8 | - define("KS3_API_PATH", __DIR__); |
|
8 | + define("KS3_API_PATH", __DIR__); |
|
9 | 9 | } |
10 | 10 | //是否使用VHOST |
11 | 11 | if (!defined("KS3_API_VHOST")) { |
12 | - define("KS3_API_VHOST", FALSE); |
|
12 | + define("KS3_API_VHOST", FALSE); |
|
13 | 13 | } |
14 | 14 | //是否开启日志(写入日志文件) |
15 | 15 | if (!defined("KS3_API_LOG")) { |
16 | - define("KS3_API_LOG", FALSE); |
|
16 | + define("KS3_API_LOG", FALSE); |
|
17 | 17 | } |
18 | 18 | //是否显示日志(直接输出日志) |
19 | 19 | if (!defined("KS3_API_DISPLAY_LOG")) { |
20 | - define("KS3_API_DISPLAY_LOG", FALSE); |
|
20 | + define("KS3_API_DISPLAY_LOG", FALSE); |
|
21 | 21 | } |
22 | 22 | //定义日志目录(默认是该项目log下) |
23 | 23 | if (!defined("KS3_API_LOG_PATH")) { |
24 | - define("KS3_API_LOG_PATH", ""); |
|
24 | + define("KS3_API_LOG_PATH", ""); |
|
25 | 25 | } |
26 | 26 | //是否使用HTTPS |
27 | 27 | if (!defined("KS3_API_USE_HTTPS")) { |
28 | - define("KS3_API_USE_HTTPS", FALSE); |
|
28 | + define("KS3_API_USE_HTTPS", FALSE); |
|
29 | 29 | } |
30 | 30 | //是否开启curl debug模式 |
31 | 31 | if (!defined("KS3_API_DEBUG_MODE")) { |
32 | - define("KS3_API_DEBUG_MODE", FALSE); |
|
32 | + define("KS3_API_DEBUG_MODE", FALSE); |
|
33 | 33 | } |
34 | 34 | define("KS3_API_Author", "[email protected]"); |
35 | 35 | define("KS3_API_Version", "1.2"); |
@@ -84,45 +84,45 @@ discard block |
||
84 | 84 | $this->log = new Logger(); |
85 | 85 | } |
86 | 86 | |
87 | - /** |
|
88 | - * 方法列表:(具体使用请参考readme.md) |
|
89 | - * listBuckets,罗列bucket |
|
90 | - * deleteBucket,删除bucket |
|
91 | - * deleteBucketCORS,删除bucket跨域配置 |
|
92 | - * createBucket,新建bucket |
|
93 | - * setBucketAcl,设置bucket访问权限 |
|
94 | - * setBucketCORS,设置bucket跨域配置 |
|
95 | - * setBucketLogging,设置bucket日志配置 |
|
96 | - * listObjects,罗列object |
|
97 | - * getBucketAcl,获取bucket访问权限 |
|
98 | - * getBucketCORS,获取bucket跨域配置 |
|
99 | - * getBucketLocation,获取bucket地点配置 |
|
100 | - * getBucketLogging,获取bucket日志配置 |
|
101 | - * bucketExists,判断bucket是否存在 |
|
102 | - * listMutipartUploads,罗列当前bucket下尚未结束的分块上传 |
|
103 | - * putObjectByContent,上传文件 |
|
104 | - * putObjectByFile,上传文件 |
|
105 | - * setObjectAcl,设置object访问权限 |
|
106 | - * copyObject,复制object |
|
107 | - * getObjectMeta,获取object元数据 |
|
108 | - * objectExists,判断object是否存在 |
|
109 | - * deleteObject,删除object |
|
110 | - * deleteObjects,删除多个object |
|
111 | - * getObject,下载object |
|
112 | - * getObjectAcl,获取object访问权限 |
|
113 | - * initMultipartUpload,初始化分块上传 |
|
114 | - * uploadPart,上传块 |
|
115 | - * abortMultipartUpload,终止分块上传 |
|
116 | - * listParts,罗列已经上传的块 |
|
117 | - * completeMultipartUpload,完成分块上传 |
|
118 | - * generatePresignedUrl,生成文件外链 |
|
119 | - * putAdp,添加异步数据处理任务 |
|
120 | - * getAdp,查询异步数据处理任务 |
|
121 | - * @param $method |
|
122 | - * @param array $args |
|
123 | - * @return ResponseCore|string|string[]|null |
|
124 | - * @throws Exception |
|
125 | - */ |
|
87 | + /** |
|
88 | + * 方法列表:(具体使用请参考readme.md) |
|
89 | + * listBuckets,罗列bucket |
|
90 | + * deleteBucket,删除bucket |
|
91 | + * deleteBucketCORS,删除bucket跨域配置 |
|
92 | + * createBucket,新建bucket |
|
93 | + * setBucketAcl,设置bucket访问权限 |
|
94 | + * setBucketCORS,设置bucket跨域配置 |
|
95 | + * setBucketLogging,设置bucket日志配置 |
|
96 | + * listObjects,罗列object |
|
97 | + * getBucketAcl,获取bucket访问权限 |
|
98 | + * getBucketCORS,获取bucket跨域配置 |
|
99 | + * getBucketLocation,获取bucket地点配置 |
|
100 | + * getBucketLogging,获取bucket日志配置 |
|
101 | + * bucketExists,判断bucket是否存在 |
|
102 | + * listMutipartUploads,罗列当前bucket下尚未结束的分块上传 |
|
103 | + * putObjectByContent,上传文件 |
|
104 | + * putObjectByFile,上传文件 |
|
105 | + * setObjectAcl,设置object访问权限 |
|
106 | + * copyObject,复制object |
|
107 | + * getObjectMeta,获取object元数据 |
|
108 | + * objectExists,判断object是否存在 |
|
109 | + * deleteObject,删除object |
|
110 | + * deleteObjects,删除多个object |
|
111 | + * getObject,下载object |
|
112 | + * getObjectAcl,获取object访问权限 |
|
113 | + * initMultipartUpload,初始化分块上传 |
|
114 | + * uploadPart,上传块 |
|
115 | + * abortMultipartUpload,终止分块上传 |
|
116 | + * listParts,罗列已经上传的块 |
|
117 | + * completeMultipartUpload,完成分块上传 |
|
118 | + * generatePresignedUrl,生成文件外链 |
|
119 | + * putAdp,添加异步数据处理任务 |
|
120 | + * getAdp,查询异步数据处理任务 |
|
121 | + * @param $method |
|
122 | + * @param array $args |
|
123 | + * @return ResponseCore|string|string[]|null |
|
124 | + * @throws Exception |
|
125 | + */ |
|
126 | 126 | public function __call($method, $args = array()) |
127 | 127 | { |
128 | 128 | $holder = new MessageHolder(); |
@@ -139,8 +139,8 @@ discard block |
||
139 | 139 | $holder->msg .= "------------------Logging End-------------------------\r\n"; |
140 | 140 | $this->log->info($holder->msg); |
141 | 141 | if ($ex != NULL) { |
142 | - throw $ex; |
|
143 | - } |
|
142 | + throw $ex; |
|
143 | + } |
|
144 | 144 | return $result; |
145 | 145 | } |
146 | 146 | |
@@ -167,8 +167,8 @@ discard block |
||
167 | 167 | } else { |
168 | 168 | $request->bucket = $args["Bucket"]; |
169 | 169 | } |
170 | - $position = $api["objectPostion"] ?? "Key"; |
|
171 | - if (empty($args[$position])) { |
|
170 | + $position = $api["objectPostion"] ?? "Key"; |
|
171 | + if (empty($args[$position])) { |
|
172 | 172 | if ($api["needObject"]) { |
173 | 173 | throw new Ks3ClientException($method . " this api need " . $position); |
174 | 174 | } |
@@ -192,11 +192,11 @@ discard block |
||
192 | 192 | $request->method = $api["method"]; |
193 | 193 | } |
194 | 194 | if (KS3_API_USE_HTTPS) { |
195 | - $request->scheme = "https://"; |
|
196 | - } |
|
195 | + $request->scheme = "https://"; |
|
196 | + } |
|
197 | 197 | else { |
198 | - $request->scheme = "http://"; |
|
199 | - } |
|
198 | + $request->scheme = "http://"; |
|
199 | + } |
|
200 | 200 | $request->endpoint = $this->endpoint; |
201 | 201 | //add subresource |
202 | 202 | if (!empty($api["subResource"])) { |
@@ -231,16 +231,16 @@ discard block |
||
231 | 231 | break; |
232 | 232 | } |
233 | 233 | |
234 | - $curIndexArg = $curIndexArg[$value1]; |
|
235 | - } |
|
234 | + $curIndexArg = $curIndexArg[$value1]; |
|
235 | + } |
|
236 | 236 | } |
237 | 237 | if (!empty($curIndexArg) && $add) { |
238 | 238 | $request->addQueryParams($curkey, $curIndexArg); |
239 | 239 | continue; |
240 | 240 | } |
241 | 241 | if ($required) { |
242 | - throw new Ks3ClientException($method . " param " . $value . " is required"); |
|
243 | - } |
|
242 | + throw new Ks3ClientException($method . " param " . $value . " is required"); |
|
243 | + } |
|
244 | 244 | } |
245 | 245 | } |
246 | 246 | if (isset($api["body"])) { |
@@ -286,12 +286,12 @@ discard block |
||
286 | 286 | if ($signer === NULL || !($signer instanceof QueryAuthSigner)) { |
287 | 287 | $url = $request->toUrl($this->endpoint); |
288 | 288 | if ($location != NULL) { |
289 | - $url = $location; |
|
290 | - } |
|
289 | + $url = $location; |
|
290 | + } |
|
291 | 291 | $httpRequest = new RequestCore($url); |
292 | 292 | if (KS3_API_DEBUG_MODE === TRUE) { |
293 | - $httpRequest->debug_mode = TRUE; |
|
294 | - } |
|
293 | + $httpRequest->debug_mode = TRUE; |
|
294 | + } |
|
295 | 295 | $httpRequest->set_method($request->method); |
296 | 296 | foreach ($request->headers as $key => $value) { |
297 | 297 | $httpRequest->add_header($key, $value); |
@@ -351,14 +351,14 @@ discard block |
||
351 | 351 | return $data; |
352 | 352 | } |
353 | 353 | |
354 | - $url = $request->toUrl($this->endpoint); |
|
355 | - $holder->msg .= $url . "\r\n"; |
|
356 | - return $url; |
|
357 | - } |
|
354 | + $url = $request->toUrl($this->endpoint); |
|
355 | + $holder->msg .= $url . "\r\n"; |
|
356 | + return $url; |
|
357 | + } |
|
358 | 358 | |
359 | 359 | //用于生产表单上传时的签名信息 |
360 | 360 | public function postObject($bucket, $postFormData = array(), $unknowValueFormFiled = array(), $filename = NULL, $expire = 18000): array |
361 | - { |
|
361 | + { |
|
362 | 362 | $policy = array(); |
363 | 363 | |
364 | 364 | $expireTime = Utils::iso8601(time() + $expire); |
@@ -34,16 +34,16 @@ discard block |
||
34 | 34 | define("KS3_API_Author", "[email protected]"); |
35 | 35 | define("KS3_API_Version", "1.2"); |
36 | 36 | |
37 | -require_once KS3_API_PATH . DIRECTORY_SEPARATOR . "config" . DIRECTORY_SEPARATOR . "Consts.php"; |
|
38 | -require_once KS3_API_PATH . DIRECTORY_SEPARATOR . "core" . DIRECTORY_SEPARATOR . "API.php"; |
|
39 | -require_once KS3_API_PATH . DIRECTORY_SEPARATOR . "core" . DIRECTORY_SEPARATOR . "Signers.php"; |
|
40 | -require_once KS3_API_PATH . DIRECTORY_SEPARATOR . "core" . DIRECTORY_SEPARATOR . "Ks3Request.class.php"; |
|
41 | -require_once KS3_API_PATH . DIRECTORY_SEPARATOR . "core" . DIRECTORY_SEPARATOR . "Handlers.php"; |
|
42 | -require_once KS3_API_PATH . DIRECTORY_SEPARATOR . "core" . DIRECTORY_SEPARATOR . "Builders.php"; |
|
43 | -require_once KS3_API_PATH . DIRECTORY_SEPARATOR . "core" . DIRECTORY_SEPARATOR . "Logger.php"; |
|
44 | -require_once KS3_API_PATH . DIRECTORY_SEPARATOR . "core" . DIRECTORY_SEPARATOR . "MessageHolder.php"; |
|
45 | -require_once KS3_API_PATH . DIRECTORY_SEPARATOR . "lib" . DIRECTORY_SEPARATOR . "RequestCore.class.php"; |
|
46 | -require_once KS3_API_PATH . DIRECTORY_SEPARATOR . "exceptions" . DIRECTORY_SEPARATOR . "Exceptions.php"; |
|
37 | +require_once KS3_API_PATH.DIRECTORY_SEPARATOR."config".DIRECTORY_SEPARATOR."Consts.php"; |
|
38 | +require_once KS3_API_PATH.DIRECTORY_SEPARATOR."core".DIRECTORY_SEPARATOR."API.php"; |
|
39 | +require_once KS3_API_PATH.DIRECTORY_SEPARATOR."core".DIRECTORY_SEPARATOR."Signers.php"; |
|
40 | +require_once KS3_API_PATH.DIRECTORY_SEPARATOR."core".DIRECTORY_SEPARATOR."Ks3Request.class.php"; |
|
41 | +require_once KS3_API_PATH.DIRECTORY_SEPARATOR."core".DIRECTORY_SEPARATOR."Handlers.php"; |
|
42 | +require_once KS3_API_PATH.DIRECTORY_SEPARATOR."core".DIRECTORY_SEPARATOR."Builders.php"; |
|
43 | +require_once KS3_API_PATH.DIRECTORY_SEPARATOR."core".DIRECTORY_SEPARATOR."Logger.php"; |
|
44 | +require_once KS3_API_PATH.DIRECTORY_SEPARATOR."core".DIRECTORY_SEPARATOR."MessageHolder.php"; |
|
45 | +require_once KS3_API_PATH.DIRECTORY_SEPARATOR."lib".DIRECTORY_SEPARATOR."RequestCore.class.php"; |
|
46 | +require_once KS3_API_PATH.DIRECTORY_SEPARATOR."exceptions".DIRECTORY_SEPARATOR."Exceptions.php"; |
|
47 | 47 | |
48 | 48 | if (function_exists('get_loaded_extensions')) { |
49 | 49 | //检测curl扩展 |
@@ -56,10 +56,10 @@ discard block |
||
56 | 56 | throw new Ks3ClientException("please install mbstring extension"); |
57 | 57 | |
58 | 58 | } |
59 | - } else { |
|
59 | + }else { |
|
60 | 60 | throw new Ks3ClientException("please install extensions"); |
61 | 61 | } |
62 | -} else { |
|
62 | +}else { |
|
63 | 63 | throw new Ks3ClientException(); |
64 | 64 | } |
65 | 65 | |
@@ -128,12 +128,12 @@ discard block |
||
128 | 128 | $holder = new MessageHolder(); |
129 | 129 | |
130 | 130 | $holder->msg = "------------------Logging Start-------------------------\r\n"; |
131 | - $holder->msg .= "method->" . $method . " args->" . serialize($args) . "\r\n"; |
|
131 | + $holder->msg .= "method->".$method." args->".serialize($args)."\r\n"; |
|
132 | 132 | $ex = NULL; |
133 | 133 | try { |
134 | 134 | $result = $this->invoke($method, $args, $holder); |
135 | 135 | } catch (Exception $e) { |
136 | - $holder->msg .= $e . "\r\n"; |
|
136 | + $holder->msg .= $e."\r\n"; |
|
137 | 137 | $ex = $e; |
138 | 138 | } |
139 | 139 | $holder->msg .= "------------------Logging End-------------------------\r\n"; |
@@ -148,7 +148,7 @@ discard block |
||
148 | 148 | { |
149 | 149 | $api = API::$API[$method]; |
150 | 150 | if (!$api) { |
151 | - throw new Ks3ClientException($method . " Not Found API"); |
|
151 | + throw new Ks3ClientException($method." Not Found API"); |
|
152 | 152 | } |
153 | 153 | if (count($args) !== 0) { |
154 | 154 | if (count($args) > 1 || !is_array($args[0])) { |
@@ -162,20 +162,20 @@ discard block |
||
162 | 162 | $request = new Ks3Request(); |
163 | 163 | if (empty($args["Bucket"])) { |
164 | 164 | if ($api["needBucket"]) { |
165 | - throw new Ks3ClientException($method . " this api need bucket"); |
|
165 | + throw new Ks3ClientException($method." this api need bucket"); |
|
166 | 166 | } |
167 | - } else { |
|
167 | + }else { |
|
168 | 168 | $request->bucket = $args["Bucket"]; |
169 | 169 | } |
170 | 170 | $position = $api["objectPostion"] ?? "Key"; |
171 | 171 | if (empty($args[$position])) { |
172 | 172 | if ($api["needObject"]) { |
173 | - throw new Ks3ClientException($method . " this api need " . $position); |
|
173 | + throw new Ks3ClientException($method." this api need ".$position); |
|
174 | 174 | } |
175 | - } else { |
|
175 | + }else { |
|
176 | 176 | $key = $args[$position]; |
177 | 177 | $preEncoding = mb_detect_encoding($key, array("ASCII", "UTF-8", "GB2312", "GBK", "BIG5")); |
178 | - $holder->msg .= "key encoding " . $preEncoding . "\r\n"; |
|
178 | + $holder->msg .= "key encoding ".$preEncoding."\r\n"; |
|
179 | 179 | if (strtolower($preEncoding) !== "utf-8") { |
180 | 180 | $key = iconv($preEncoding, "UTF-8", $key); |
181 | 181 | } |
@@ -185,10 +185,10 @@ discard block |
||
185 | 185 | if ($method === "Method") { |
186 | 186 | if (empty($args["Method"])) { |
187 | 187 | $request->method = "GET"; |
188 | - } else { |
|
188 | + }else { |
|
189 | 189 | $request->method = $args["Method"]; |
190 | 190 | } |
191 | - } else { |
|
191 | + }else { |
|
192 | 192 | $request->method = $api["method"]; |
193 | 193 | } |
194 | 194 | if (KS3_API_USE_HTTPS) { |
@@ -217,7 +217,7 @@ discard block |
||
217 | 217 | foreach ($index as $key1 => $value1) { |
218 | 218 | if (!isset($curIndexArg[$value1]) && $value1 !== "*") { |
219 | 219 | $add = FALSE; |
220 | - } else { |
|
220 | + }else { |
|
221 | 221 | $curkey = $value1; |
222 | 222 | //星号表示所有,按照暂时的业务,默认星号后面就没了 |
223 | 223 | if ($curkey === "*") { |
@@ -239,7 +239,7 @@ discard block |
||
239 | 239 | continue; |
240 | 240 | } |
241 | 241 | if ($required) { |
242 | - throw new Ks3ClientException($method . " param " . $value . " is required"); |
|
242 | + throw new Ks3ClientException($method." param ".$value." is required"); |
|
243 | 243 | } |
244 | 244 | } |
245 | 245 | } |
@@ -248,7 +248,7 @@ discard block |
||
248 | 248 | $builderName = $api["body"]["builder"]; |
249 | 249 | $builder = new $builderName(); |
250 | 250 | $request->body = $builder->build($args); |
251 | - } else if (isset($api["body"]["position"])) { |
|
251 | + }else if (isset($api["body"]["position"])) { |
|
252 | 252 | $position = $api["body"]["position"]; |
253 | 253 | $index = explode("->", $position); |
254 | 254 | $curIndexArg = $args; |
@@ -257,7 +257,7 @@ discard block |
||
257 | 257 | foreach ($index as $key1 => $value1) { |
258 | 258 | if (!isset($curIndexArg[$value1])) { |
259 | 259 | $add = FALSE; |
260 | - } else { |
|
260 | + }else { |
|
261 | 261 | $curIndexArg = $curIndexArg[$value1]; |
262 | 262 | $curkey = $value1; |
263 | 263 | } |
@@ -278,7 +278,7 @@ discard block |
||
278 | 278 | $signer = new $value(); |
279 | 279 | $log = $signer->sign($request, array("accessKey" => $this->accessKey, "secretKey" => $this->secretKey, "args" => $args)); |
280 | 280 | if (!empty($log)) { |
281 | - $holder->msg .= $log . "\r\n"; |
|
281 | + $holder->msg .= $log."\r\n"; |
|
282 | 282 | } |
283 | 283 | } |
284 | 284 | } |
@@ -318,31 +318,31 @@ discard block |
||
318 | 318 | $httpRequest->set_write_stream($write_stream); |
319 | 319 | } |
320 | 320 | |
321 | - $holder->msg .= "request url->" . serialize($httpRequest->request_url) . "\r\n"; |
|
322 | - $holder->msg .= "request headers->" . serialize($httpRequest->request_headers) . "\r\n"; |
|
323 | - $holder->msg .= "request body->" . $httpRequest->request_body . "\r\n"; |
|
324 | - $holder->msg .= "request read stream length->" . $read_length . "\r\n"; |
|
325 | - $holder->msg .= "request read stream seek position->" . $seek_position . "\r\n"; |
|
321 | + $holder->msg .= "request url->".serialize($httpRequest->request_url)."\r\n"; |
|
322 | + $holder->msg .= "request headers->".serialize($httpRequest->request_headers)."\r\n"; |
|
323 | + $holder->msg .= "request body->".$httpRequest->request_body."\r\n"; |
|
324 | + $holder->msg .= "request read stream length->".$read_length."\r\n"; |
|
325 | + $holder->msg .= "request read stream seek position->".$seek_position."\r\n"; |
|
326 | 326 | $httpRequest->send_request(); |
327 | 327 | //print_r($httpRequest); |
328 | 328 | $body = $httpRequest->get_response_body(); |
329 | - $data = new ResponseCore ($httpRequest->get_response_header(), Utils::replaceNS2($body), $httpRequest->get_response_code()); |
|
329 | + $data = new ResponseCore($httpRequest->get_response_header(), Utils::replaceNS2($body), $httpRequest->get_response_code()); |
|
330 | 330 | |
331 | 331 | if ($data->status == 307) { |
332 | 332 | $respHeaders = $httpRequest->get_response_header(); |
333 | 333 | $location = $respHeaders["location"]; |
334 | 334 | if (strpos($location, "http") === 0) { |
335 | - $holder->msg .= "response code->" . $httpRequest->get_response_code() . "\r\n"; |
|
336 | - $holder->msg .= "response headers->" . serialize($httpRequest->get_response_header()) . "\r\n"; |
|
337 | - $holder->msg .= "response body->" . $body . "\r\n"; |
|
338 | - $holder->msg .= "retry request to " . $location . "\r\n"; |
|
335 | + $holder->msg .= "response code->".$httpRequest->get_response_code()."\r\n"; |
|
336 | + $holder->msg .= "response headers->".serialize($httpRequest->get_response_header())."\r\n"; |
|
337 | + $holder->msg .= "response body->".$body."\r\n"; |
|
338 | + $holder->msg .= "retry request to ".$location."\r\n"; |
|
339 | 339 | //array($args)详见invoke开头 |
340 | 340 | return $this->invoke($method, array($args), $holder, $location); |
341 | 341 | } |
342 | 342 | } |
343 | - $holder->msg .= "response code->" . $httpRequest->get_response_code() . "\r\n"; |
|
344 | - $holder->msg .= "response headers->" . serialize($httpRequest->get_response_header()) . "\r\n"; |
|
345 | - $holder->msg .= "response body->" . $body . "\r\n"; |
|
343 | + $holder->msg .= "response code->".$httpRequest->get_response_code()."\r\n"; |
|
344 | + $holder->msg .= "response headers->".serialize($httpRequest->get_response_header())."\r\n"; |
|
345 | + $holder->msg .= "response body->".$body."\r\n"; |
|
346 | 346 | $handlers = explode("->", $api["handler"]); |
347 | 347 | foreach ($handlers as $key => $value) { |
348 | 348 | $handler = new $value(); |
@@ -352,7 +352,7 @@ discard block |
||
352 | 352 | } |
353 | 353 | |
354 | 354 | $url = $request->toUrl($this->endpoint); |
355 | - $holder->msg .= $url . "\r\n"; |
|
355 | + $holder->msg .= $url."\r\n"; |
|
356 | 356 | return $url; |
357 | 357 | } |
358 | 358 | |
@@ -361,7 +361,7 @@ discard block |
||
361 | 361 | { |
362 | 362 | $policy = array(); |
363 | 363 | |
364 | - $expireTime = Utils::iso8601(time() + $expire); |
|
364 | + $expireTime = Utils::iso8601(time()+$expire); |
|
365 | 365 | $policy["expiration"] = $expireTime; |
366 | 366 | $postFormData["bucket"] = $bucket; |
367 | 367 | $conditions = array(); |
@@ -373,7 +373,7 @@ discard block |
||
373 | 373 | foreach ($unknowValueFormFiled as $key => $value) { |
374 | 374 | $condition = array(); |
375 | 375 | $condition[] = "starts-with"; |
376 | - $condition[] = "\$" . $value; |
|
376 | + $condition[] = "\$".$value; |
|
377 | 377 | $condition[] = ""; |
378 | 378 | $conditions[] = $condition; |
379 | 379 | } |
@@ -193,8 +193,7 @@ |
||
193 | 193 | } |
194 | 194 | if (KS3_API_USE_HTTPS) { |
195 | 195 | $request->scheme = "https://"; |
196 | - } |
|
197 | - else { |
|
196 | + } else { |
|
198 | 197 | $request->scheme = "http://"; |
199 | 198 | } |
200 | 199 | $request->endpoint = $this->endpoint; |
@@ -83,7 +83,7 @@ discard block |
||
83 | 83 | */ |
84 | 84 | public function upload(string $object, string $filePath): ?bool |
85 | 85 | { |
86 | - require_once(__DIR__ . "/bin/Ks3Client.class.php"); |
|
86 | + require_once(__DIR__."/bin/Ks3Client.class.php"); |
|
87 | 87 | $client = new Ks3Client($this->accessKeyID, $this->accessKeySecret, $this->endpoint); |
88 | 88 | $content = fopen($filePath, 'rb'); |
89 | 89 | $args = [ |
@@ -91,10 +91,10 @@ discard block |
||
91 | 91 | "Key" => $object, |
92 | 92 | "Content" => [ |
93 | 93 | //要上传的内容 |
94 | - "content" => $content,//可以是文件路径或者resource,如果文件大于2G,请提供文件路径 |
|
94 | + "content" => $content, //可以是文件路径或者resource,如果文件大于2G,请提供文件路径 |
|
95 | 95 | "seek_position" => 0//跳过文件开头?个字节 |
96 | 96 | ], |
97 | - "ACL" => "public-read",//可以设置访问权限,合法值,private、public-read |
|
97 | + "ACL" => "public-read", //可以设置访问权限,合法值,private、public-read |
|
98 | 98 | "ObjectMeta" => [ |
99 | 99 | //设置object的元数据,可以设置"Cache-Control","Content-Disposition","Content-Encoding","Content-Length","Content-MD5","Content-Type","Expires"。当设置了Content-Length时,最后上传的为从seek_position开始向后Content-Length个字节的内容。当设置了Content-MD5时,系统会在服务端进行md5校验。 |
100 | 100 | "Content-Type" => "binay/ocet-stream" |
@@ -46,7 +46,7 @@ discard block |
||
46 | 46 | { |
47 | 47 | if (Pregs::isLink($url)) { |
48 | 48 | $this->url = $url; |
49 | - } else { |
|
49 | + }else { |
|
50 | 50 | preg_match_all('#\bhttps?://[^,\s()<>]+(?:\([\w\d]+\)|([^,[:punct:]\s]|/))#', $url, $match); |
51 | 51 | $this->url = $match[0][0]; |
52 | 52 | } |
@@ -107,9 +107,9 @@ discard block |
||
107 | 107 | 'Connection' => 'keep-alive', |
108 | 108 | 'User-Agent' => 'Mozilla/5.0 (iPhone; CPU iPhone OS 12_1_4 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/16D57 Version/12.0 Safari/604.1' |
109 | 109 | ]; |
110 | - $client = new Client(['timeout' => 2, 'headers' => $headers, 'http_errors' => false,]); |
|
110 | + $client = new Client(['timeout' => 2, 'headers' => $headers, 'http_errors' => false, ]); |
|
111 | 111 | $data['headers'] = $headers; |
112 | - $data['verify'] = __DIR__ . DIRECTORY_SEPARATOR . 'cacert.pem'; |
|
112 | + $data['verify'] = __DIR__.DIRECTORY_SEPARATOR.'cacert.pem'; |
|
113 | 113 | $jar = new CookieJar(); |
114 | 114 | $data['cookies'] = $jar; |
115 | 115 | $response = $client->request('GET', $url, $data); |