@@ -1,53 +1,53 @@ |
||
1 | 1 | <?php |
2 | 2 | function rangeGetAndCheckMd5($client,$bucket,$key,$file,$expectedMd5){ |
3 | - $args = array("Bucket"=>$bucket,"Key"=>$key); |
|
4 | - $meta = $client->getObjectMeta($args); |
|
5 | - $contentlength = $meta["ObjectMeta"]["Content-Length"]; |
|
3 | + $args = array("Bucket"=>$bucket,"Key"=>$key); |
|
4 | + $meta = $client->getObjectMeta($args); |
|
5 | + $contentlength = $meta["ObjectMeta"]["Content-Length"]; |
|
6 | 6 | |
7 | - $filelist = array(); |
|
7 | + $filelist = array(); |
|
8 | 8 | |
9 | - for($begin = 0;$begin <$contentlength;){ |
|
10 | - $index = rand((int)($contentlength/20),(int)($contentlength/4)); |
|
11 | - $range = array("start"=>$begin,"end"=>$begin+$index); |
|
12 | - $destFile = $file.$begin."-".($begin+$index); |
|
13 | - array_push($filelist,$destFile); |
|
14 | - $begin += ($index+1); |
|
15 | - $args = array( |
|
16 | - "Bucket"=>$bucket, |
|
17 | - "Key"=>$key, |
|
18 | - "Range"=>$range, |
|
19 | - "WriteTo"=>$destFile |
|
20 | - ); |
|
21 | - $client->getObject($args); |
|
22 | - } |
|
9 | + for($begin = 0;$begin <$contentlength;){ |
|
10 | + $index = rand((int)($contentlength/20),(int)($contentlength/4)); |
|
11 | + $range = array("start"=>$begin,"end"=>$begin+$index); |
|
12 | + $destFile = $file.$begin."-".($begin+$index); |
|
13 | + array_push($filelist,$destFile); |
|
14 | + $begin += ($index+1); |
|
15 | + $args = array( |
|
16 | + "Bucket"=>$bucket, |
|
17 | + "Key"=>$key, |
|
18 | + "Range"=>$range, |
|
19 | + "WriteTo"=>$destFile |
|
20 | + ); |
|
21 | + $client->getObject($args); |
|
22 | + } |
|
23 | 23 | |
24 | - foreach ($filelist as $key => $value) { |
|
25 | - $handle = fopen($value,"r"); |
|
26 | - $size = filesize($value); |
|
27 | - if($size > 0){ |
|
28 | - $content = fread($handle,$size); |
|
29 | - file_put_contents($file,$content,FILE_APPEND); |
|
30 | - } |
|
31 | - fclose($handle); |
|
32 | - //@unlink($value); |
|
33 | - } |
|
34 | - $md5 = md5_file($file); |
|
35 | - //@unlink($file); |
|
36 | - if($md5 != $expectedMd5) |
|
37 | - throw new Exception("file md5 check error expected ".$expectedMd5." ,actual ".$md5, 1); |
|
38 | - foreach ($filelist as $key => $value) { |
|
39 | - @unlink($value); |
|
40 | - } |
|
41 | - @unlink($file); |
|
24 | + foreach ($filelist as $key => $value) { |
|
25 | + $handle = fopen($value,"r"); |
|
26 | + $size = filesize($value); |
|
27 | + if($size > 0){ |
|
28 | + $content = fread($handle,$size); |
|
29 | + file_put_contents($file,$content,FILE_APPEND); |
|
30 | + } |
|
31 | + fclose($handle); |
|
32 | + //@unlink($value); |
|
33 | + } |
|
34 | + $md5 = md5_file($file); |
|
35 | + //@unlink($file); |
|
36 | + if($md5 != $expectedMd5) |
|
37 | + throw new Exception("file md5 check error expected ".$expectedMd5." ,actual ".$md5, 1); |
|
38 | + foreach ($filelist as $key => $value) { |
|
39 | + @unlink($value); |
|
40 | + } |
|
41 | + @unlink($file); |
|
42 | 42 | } |
43 | 43 | function generateFile($sizeInBytes,$destFile){ |
44 | - for($i = 0;$i < $sizeInBytes/10;$i++){ |
|
45 | - $randpwd = ""; |
|
46 | - for ($j = 0; $j < 10; $j++) |
|
47 | - { |
|
48 | - $randpwd .= chr(mt_rand(33, 126)); |
|
49 | - } |
|
50 | - file_put_contents($destFile,$randpwd,FILE_APPEND); |
|
51 | - } |
|
44 | + for($i = 0;$i < $sizeInBytes/10;$i++){ |
|
45 | + $randpwd = ""; |
|
46 | + for ($j = 0; $j < 10; $j++) |
|
47 | + { |
|
48 | + $randpwd .= chr(mt_rand(33, 126)); |
|
49 | + } |
|
50 | + file_put_contents($destFile,$randpwd,FILE_APPEND); |
|
51 | + } |
|
52 | 52 | } |
53 | 53 | ?> |
54 | 54 | \ No newline at end of file |
@@ -1,16 +1,16 @@ discard block |
||
1 | 1 | <?php |
2 | -function rangeGetAndCheckMd5($client,$bucket,$key,$file,$expectedMd5){ |
|
3 | - $args = array("Bucket"=>$bucket,"Key"=>$key); |
|
2 | +function rangeGetAndCheckMd5($client, $bucket, $key, $file, $expectedMd5) { |
|
3 | + $args = array("Bucket"=>$bucket, "Key"=>$key); |
|
4 | 4 | $meta = $client->getObjectMeta($args); |
5 | 5 | $contentlength = $meta["ObjectMeta"]["Content-Length"]; |
6 | 6 | |
7 | 7 | $filelist = array(); |
8 | 8 | |
9 | - for($begin = 0;$begin <$contentlength;){ |
|
10 | - $index = rand((int)($contentlength/20),(int)($contentlength/4)); |
|
11 | - $range = array("start"=>$begin,"end"=>$begin+$index); |
|
9 | + for ($begin = 0; $begin < $contentlength;) { |
|
10 | + $index = rand((int)($contentlength/20), (int)($contentlength/4)); |
|
11 | + $range = array("start"=>$begin, "end"=>$begin+$index); |
|
12 | 12 | $destFile = $file.$begin."-".($begin+$index); |
13 | - array_push($filelist,$destFile); |
|
13 | + array_push($filelist, $destFile); |
|
14 | 14 | $begin += ($index+1); |
15 | 15 | $args = array( |
16 | 16 | "Bucket"=>$bucket, |
@@ -22,32 +22,32 @@ discard block |
||
22 | 22 | } |
23 | 23 | |
24 | 24 | foreach ($filelist as $key => $value) { |
25 | - $handle = fopen($value,"r"); |
|
25 | + $handle = fopen($value, "r"); |
|
26 | 26 | $size = filesize($value); |
27 | - if($size > 0){ |
|
28 | - $content = fread($handle,$size); |
|
29 | - file_put_contents($file,$content,FILE_APPEND); |
|
27 | + if ($size > 0) { |
|
28 | + $content = fread($handle, $size); |
|
29 | + file_put_contents($file, $content, FILE_APPEND); |
|
30 | 30 | } |
31 | 31 | fclose($handle); |
32 | 32 | //@unlink($value); |
33 | 33 | } |
34 | 34 | $md5 = md5_file($file); |
35 | 35 | //@unlink($file); |
36 | - if($md5 != $expectedMd5) |
|
36 | + if ($md5 != $expectedMd5) |
|
37 | 37 | throw new Exception("file md5 check error expected ".$expectedMd5." ,actual ".$md5, 1); |
38 | 38 | foreach ($filelist as $key => $value) { |
39 | 39 | @unlink($value); |
40 | 40 | } |
41 | 41 | @unlink($file); |
42 | 42 | } |
43 | -function generateFile($sizeInBytes,$destFile){ |
|
44 | - for($i = 0;$i < $sizeInBytes/10;$i++){ |
|
43 | +function generateFile($sizeInBytes, $destFile) { |
|
44 | + for ($i = 0; $i < $sizeInBytes/10; $i++) { |
|
45 | 45 | $randpwd = ""; |
46 | 46 | for ($j = 0; $j < 10; $j++) |
47 | 47 | { |
48 | 48 | $randpwd .= chr(mt_rand(33, 126)); |
49 | 49 | } |
50 | - file_put_contents($destFile,$randpwd,FILE_APPEND); |
|
50 | + file_put_contents($destFile, $randpwd, FILE_APPEND); |
|
51 | 51 | } |
52 | 52 | } |
53 | 53 | ?> |
54 | 54 | \ No newline at end of file |
@@ -33,8 +33,9 @@ |
||
33 | 33 | } |
34 | 34 | $md5 = md5_file($file); |
35 | 35 | //@unlink($file); |
36 | - if($md5 != $expectedMd5) |
|
37 | - throw new Exception("file md5 check error expected ".$expectedMd5." ,actual ".$md5, 1); |
|
36 | + if($md5 != $expectedMd5) { |
|
37 | + throw new Exception("file md5 check error expected ".$expectedMd5." ,actual ".$md5, 1); |
|
38 | + } |
|
38 | 39 | foreach ($filelist as $key => $value) { |
39 | 40 | @unlink($value); |
40 | 41 | } |
@@ -1,60 +1,60 @@ |
||
1 | 1 | <?php |
2 | 2 | require_once "../core/Logger.php"; |
3 | 3 | class PUnit{ |
4 | - function assertEquals($value,$expected,$info = NULL){ |
|
5 | - if($value != $expected){ |
|
6 | - throw new Exception($info." expected ".$expected." but ".$value); |
|
7 | - } |
|
8 | - } |
|
9 | - function run($torun = NULL){ |
|
10 | - $r = new ReflectionClass($this); |
|
11 | - foreach($r->getMethods() as $key=>$methodObj){ |
|
12 | - if($methodObj->isPrivate()) |
|
13 | - $methods[$key]['type'] = 'private'; |
|
14 | - elseif($methodObj->isProtected()) |
|
15 | - $methods[$key]['type'] = 'protected'; |
|
16 | - else |
|
17 | - $methods[$key]['type'] = 'public'; |
|
18 | - $methods[$key]['name'] = $methodObj->name; |
|
19 | - $methods[$key]['class'] = $methodObj->class; |
|
20 | - } |
|
4 | + function assertEquals($value,$expected,$info = NULL){ |
|
5 | + if($value != $expected){ |
|
6 | + throw new Exception($info." expected ".$expected." but ".$value); |
|
7 | + } |
|
8 | + } |
|
9 | + function run($torun = NULL){ |
|
10 | + $r = new ReflectionClass($this); |
|
11 | + foreach($r->getMethods() as $key=>$methodObj){ |
|
12 | + if($methodObj->isPrivate()) |
|
13 | + $methods[$key]['type'] = 'private'; |
|
14 | + elseif($methodObj->isProtected()) |
|
15 | + $methods[$key]['type'] = 'protected'; |
|
16 | + else |
|
17 | + $methods[$key]['type'] = 'public'; |
|
18 | + $methods[$key]['name'] = $methodObj->name; |
|
19 | + $methods[$key]['class'] = $methodObj->class; |
|
20 | + } |
|
21 | 21 | $before = NULL; |
22 | 22 | $after = NULL; |
23 | 23 | foreach ($methods as $method) { |
24 | - if($method["class"] != "PUnit"&&$method["name"] == "before"){ |
|
24 | + if($method["class"] != "PUnit"&&$method["name"] == "before"){ |
|
25 | 25 | $before = $method; |
26 | - } |
|
27 | - if($method["class"] != "PUnit"&&$method["name"] == "after"){ |
|
26 | + } |
|
27 | + if($method["class"] != "PUnit"&&$method["name"] == "after"){ |
|
28 | 28 | $after = $method; |
29 | - } |
|
29 | + } |
|
30 | 30 | } |
31 | - $error = array(); |
|
32 | - $success = array(); |
|
33 | - foreach ($methods as $method) { |
|
34 | - if($method["class"] != "PUnit"&&substr($method["name"],0,4) == "test"){ |
|
31 | + $error = array(); |
|
32 | + $success = array(); |
|
33 | + foreach ($methods as $method) { |
|
34 | + if($method["class"] != "PUnit"&&substr($method["name"],0,4) == "test"){ |
|
35 | 35 | if($torun !== NULL){ |
36 | - if(!in_array($method["name"],$torun)) |
|
36 | + if(!in_array($method["name"],$torun)) |
|
37 | 37 | continue; |
38 | 38 | } |
39 | - try{ |
|
40 | - if($method["type"] == "public"){ |
|
39 | + try{ |
|
40 | + if($method["type"] == "public"){ |
|
41 | 41 | $log = new Logger(); |
42 | 42 | $log->info("Run unit --->".$method["name"]); |
43 | 43 | if($before!=NULL) |
44 | - $this->$before["name"](); |
|
45 | - $this->$method["name"](); |
|
46 | - array_push($success,$method["name"]); |
|
47 | - } |
|
48 | - }catch(Exception $e){ |
|
49 | - $error[$method["name"]]="".$e; |
|
50 | - } |
|
51 | - } |
|
52 | - } |
|
53 | - echo "\r\nPHP Unit-----------error"."\r\n"; |
|
54 | - print_r($error); |
|
44 | + $this->$before["name"](); |
|
45 | + $this->$method["name"](); |
|
46 | + array_push($success,$method["name"]); |
|
47 | + } |
|
48 | + }catch(Exception $e){ |
|
49 | + $error[$method["name"]]="".$e; |
|
50 | + } |
|
51 | + } |
|
52 | + } |
|
53 | + echo "\r\nPHP Unit-----------error"."\r\n"; |
|
54 | + print_r($error); |
|
55 | 55 | echo "PHP Unit-----------result"."\r\n"; |
56 | 56 | echo "total:".(count($success)+count($error)).",success:".count($success).",error:".count($error)."\r\n"; |
57 | 57 | |
58 | - } |
|
58 | + } |
|
59 | 59 | } |
60 | 60 | ?> |
61 | 61 | \ No newline at end of file |
@@ -1,17 +1,17 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | require_once "../core/Logger.php"; |
3 | -class PUnit{ |
|
4 | - function assertEquals($value,$expected,$info = NULL){ |
|
5 | - if($value != $expected){ |
|
3 | +class PUnit { |
|
4 | + function assertEquals($value, $expected, $info = NULL) { |
|
5 | + if ($value != $expected) { |
|
6 | 6 | throw new Exception($info." expected ".$expected." but ".$value); |
7 | 7 | } |
8 | 8 | } |
9 | - function run($torun = NULL){ |
|
9 | + function run($torun = NULL) { |
|
10 | 10 | $r = new ReflectionClass($this); |
11 | - foreach($r->getMethods() as $key=>$methodObj){ |
|
12 | - if($methodObj->isPrivate()) |
|
11 | + foreach ($r->getMethods() as $key=>$methodObj) { |
|
12 | + if ($methodObj->isPrivate()) |
|
13 | 13 | $methods[$key]['type'] = 'private'; |
14 | - elseif($methodObj->isProtected()) |
|
14 | + elseif ($methodObj->isProtected()) |
|
15 | 15 | $methods[$key]['type'] = 'protected'; |
16 | 16 | else |
17 | 17 | $methods[$key]['type'] = 'public'; |
@@ -21,32 +21,32 @@ discard block |
||
21 | 21 | $before = NULL; |
22 | 22 | $after = NULL; |
23 | 23 | foreach ($methods as $method) { |
24 | - if($method["class"] != "PUnit"&&$method["name"] == "before"){ |
|
24 | + if ($method["class"] != "PUnit" && $method["name"] == "before") { |
|
25 | 25 | $before = $method; |
26 | 26 | } |
27 | - if($method["class"] != "PUnit"&&$method["name"] == "after"){ |
|
27 | + if ($method["class"] != "PUnit" && $method["name"] == "after") { |
|
28 | 28 | $after = $method; |
29 | 29 | } |
30 | 30 | } |
31 | 31 | $error = array(); |
32 | 32 | $success = array(); |
33 | 33 | foreach ($methods as $method) { |
34 | - if($method["class"] != "PUnit"&&substr($method["name"],0,4) == "test"){ |
|
35 | - if($torun !== NULL){ |
|
36 | - if(!in_array($method["name"],$torun)) |
|
34 | + if ($method["class"] != "PUnit" && substr($method["name"], 0, 4) == "test") { |
|
35 | + if ($torun !== NULL) { |
|
36 | + if (!in_array($method["name"], $torun)) |
|
37 | 37 | continue; |
38 | 38 | } |
39 | - try{ |
|
40 | - if($method["type"] == "public"){ |
|
39 | + try { |
|
40 | + if ($method["type"] == "public") { |
|
41 | 41 | $log = new Logger(); |
42 | 42 | $log->info("Run unit --->".$method["name"]); |
43 | - if($before!=NULL) |
|
43 | + if ($before != NULL) |
|
44 | 44 | $this->$before["name"](); |
45 | 45 | $this->$method["name"](); |
46 | - array_push($success,$method["name"]); |
|
46 | + array_push($success, $method["name"]); |
|
47 | 47 | } |
48 | - }catch(Exception $e){ |
|
49 | - $error[$method["name"]]="".$e; |
|
48 | + } catch (Exception $e) { |
|
49 | + $error[$method["name"]] = "".$e; |
|
50 | 50 | } |
51 | 51 | } |
52 | 52 | } |
@@ -9,12 +9,13 @@ discard block |
||
9 | 9 | function run($torun = NULL){ |
10 | 10 | $r = new ReflectionClass($this); |
11 | 11 | foreach($r->getMethods() as $key=>$methodObj){ |
12 | - if($methodObj->isPrivate()) |
|
13 | - $methods[$key]['type'] = 'private'; |
|
14 | - elseif($methodObj->isProtected()) |
|
15 | - $methods[$key]['type'] = 'protected'; |
|
16 | - else |
|
17 | - $methods[$key]['type'] = 'public'; |
|
12 | + if($methodObj->isPrivate()) { |
|
13 | + $methods[$key]['type'] = 'private'; |
|
14 | + } elseif($methodObj->isProtected()) { |
|
15 | + $methods[$key]['type'] = 'protected'; |
|
16 | + } else { |
|
17 | + $methods[$key]['type'] = 'public'; |
|
18 | + } |
|
18 | 19 | $methods[$key]['name'] = $methodObj->name; |
19 | 20 | $methods[$key]['class'] = $methodObj->class; |
20 | 21 | } |
@@ -33,19 +34,21 @@ discard block |
||
33 | 34 | foreach ($methods as $method) { |
34 | 35 | if($method["class"] != "PUnit"&&substr($method["name"],0,4) == "test"){ |
35 | 36 | if($torun !== NULL){ |
36 | - if(!in_array($method["name"],$torun)) |
|
37 | - continue; |
|
37 | + if(!in_array($method["name"],$torun)) { |
|
38 | + continue; |
|
39 | + } |
|
38 | 40 | } |
39 | 41 | try{ |
40 | 42 | if($method["type"] == "public"){ |
41 | 43 | $log = new Logger(); |
42 | 44 | $log->info("Run unit --->".$method["name"]); |
43 | - if($before!=NULL) |
|
44 | - $this->$before["name"](); |
|
45 | + if($before!=NULL) { |
|
46 | + $this->$before["name"](); |
|
47 | + } |
|
45 | 48 | $this->$method["name"](); |
46 | 49 | array_push($success,$method["name"]); |
47 | 50 | } |
48 | - }catch(Exception $e){ |
|
51 | + } catch(Exception $e){ |
|
49 | 52 | $error[$method["name"]]="".$e; |
50 | 53 | } |
51 | 54 | } |
@@ -81,7 +81,7 @@ discard block |
||
81 | 81 | if (empty($this->accessKeyID) || empty($this->accessKeySecret) || empty($this->endpoint)) { |
82 | 82 | $this->getConfig(); |
83 | 83 | } |
84 | - require_once(__DIR__ . "/bin/Ks3Client.class.php"); |
|
84 | + require_once(__DIR__."/bin/Ks3Client.class.php"); |
|
85 | 85 | $client = new Ks3Client($this->accessKeyID, $this->accessKeySecret, $this->endpoint); |
86 | 86 | if (empty($this->bucket)) { |
87 | 87 | $this->getConfig(); |
@@ -92,10 +92,10 @@ discard block |
||
92 | 92 | "Key" => $object, |
93 | 93 | "Content" => [ |
94 | 94 | //要上传的内容 |
95 | - "content" => $content,//可以是文件路径或者resource,如果文件大于2G,请提供文件路径 |
|
95 | + "content" => $content, //可以是文件路径或者resource,如果文件大于2G,请提供文件路径 |
|
96 | 96 | "seek_position" => 0//跳过文件开头?个字节 |
97 | 97 | ], |
98 | - "ACL" => "public-read",//可以设置访问权限,合法值,private、public-read |
|
98 | + "ACL" => "public-read", //可以设置访问权限,合法值,private、public-read |
|
99 | 99 | "ObjectMeta" => [ |
100 | 100 | //设置object的元数据,可以设置"Cache-Control","Content-Disposition","Content-Encoding","Content-Length","Content-MD5","Content-Type","Expires"。当设置了Content-Length时,最后上传的为从seek_position开始向后Content-Length个字节的内容。当设置了Content-MD5时,系统会在服务端进行md5校验。 |
101 | 101 | "Content-Type" => "binay/ocet-stream" |
@@ -108,7 +108,7 @@ discard block |
||
108 | 108 | ]; |
109 | 109 | try { |
110 | 110 | $client->putObjectByFile($args); |
111 | - return config('dtapp.ksyun.ks3.url', '') . $object; |
|
111 | + return config('dtapp.ksyun.ks3.url', '').$object; |
|
112 | 112 | } catch (Ks3ServiceException $e) { |
113 | 113 | return false; |
114 | 114 | } |
@@ -83,7 +83,7 @@ |
||
83 | 83 | $data['msgtype'] = $this->msg_type; |
84 | 84 | } |
85 | 85 | $result = HttpService::instance() |
86 | - ->url("{$this->oapi_url}robot/send?access_token=" . $this->access_token) |
|
86 | + ->url("{$this->oapi_url}robot/send?access_token=".$this->access_token) |
|
87 | 87 | ->data($data) |
88 | 88 | ->post() |
89 | 89 | ->toArray(); |
@@ -145,7 +145,7 @@ discard block |
||
145 | 145 | $sign = $this->createSign(); |
146 | 146 | //组织参数 |
147 | 147 | $strParam = $this->createStrParam(); |
148 | - $strParam .= 'sign=' . $sign; |
|
148 | + $strParam .= 'sign='.$sign; |
|
149 | 149 | //访问服务 |
150 | 150 | $result = file_get_contents("{$this->url}?{$strParam}"); |
151 | 151 | $result = json_decode($result, true); |
@@ -351,7 +351,7 @@ discard block |
||
351 | 351 | $this->params['sign_method'] = $this->sign_method; |
352 | 352 | $this->params['param_json'] = json_encode($this->param, JSON_UNESCAPED_UNICODE); |
353 | 353 | $this->http(); |
354 | - $response = Strings::replace('.', '_', $this->method) . "_response"; |
|
354 | + $response = Strings::replace('.', '_', $this->method)."_response"; |
|
355 | 355 | if (isset($this->output["$response"]['result'])) { |
356 | 356 | if (is_array($this->output["$response"]['result'])) { |
357 | 357 | return $this->output["$response"]['result']; |
@@ -360,7 +360,7 @@ discard block |
||
360 | 360 | $this->output = json_encode($this->output["$response"]['result'], JSON_UNESCAPED_UNICODE); |
361 | 361 | } |
362 | 362 | return json_decode($this->output["$response"]['result'], true); |
363 | - } else { |
|
363 | + }else { |
|
364 | 364 | if (is_array($this->output)) { |
365 | 365 | return $this->output; |
366 | 366 | } |
@@ -388,7 +388,7 @@ discard block |
||
388 | 388 | ksort($this->params); |
389 | 389 | foreach ($this->params as $key => $val) { |
390 | 390 | if ($key != '' && $val != '') { |
391 | - $sign .= $key . $val; |
|
391 | + $sign .= $key.$val; |
|
392 | 392 | } |
393 | 393 | } |
394 | 394 | $sign .= $this->secret_key; |
@@ -405,7 +405,7 @@ discard block |
||
405 | 405 | $strParam = ''; |
406 | 406 | foreach ($this->params as $key => $val) { |
407 | 407 | if ($key != '' && $val != '') { |
408 | - $strParam .= $key . '=' . urlencode($val) . '&'; |
|
408 | + $strParam .= $key.'='.urlencode($val).'&'; |
|
409 | 409 | } |
410 | 410 | } |
411 | 411 | return $strParam; |
@@ -133,15 +133,15 @@ |
||
133 | 133 | if (empty($this->path)) { |
134 | 134 | $this->getConfig(); |
135 | 135 | } |
136 | - $bytes = filesize($this->path . $name); |
|
136 | + $bytes = filesize($this->path.$name); |
|
137 | 137 | if ($bytes >= 1073741824) { |
138 | - $bytes = round($bytes / 1073741824 * 100) / 100 . 'GB'; |
|
138 | + $bytes = round($bytes/1073741824*100)/100.'GB'; |
|
139 | 139 | } elseif ($bytes >= 1048576) { |
140 | - $bytes = round($bytes / 1048576 * 100) / 100 . 'MB'; |
|
140 | + $bytes = round($bytes/1048576*100)/100.'MB'; |
|
141 | 141 | } elseif ($bytes >= 1024) { |
142 | - $bytes = round($bytes / 1024 * 100) / 100 . 'KB'; |
|
143 | - } else { |
|
144 | - $bytes = $bytes . 'Bytes'; |
|
142 | + $bytes = round($bytes/1024*100)/100.'KB'; |
|
143 | + }else { |
|
144 | + $bytes = $bytes.'Bytes'; |
|
145 | 145 | } |
146 | 146 | return $bytes; |
147 | 147 | } |
@@ -80,6 +80,6 @@ |
||
80 | 80 | $client = new Upyun($serviceConfig); |
81 | 81 | $file = fopen($filePath, 'r'); |
82 | 82 | $client->write($object, $file); |
83 | - return config('dtapp.upyun.uss.url', '') . $object; |
|
83 | + return config('dtapp.upyun.uss.url', '').$object; |
|
84 | 84 | } |
85 | 85 | } |
@@ -37,7 +37,7 @@ discard block |
||
37 | 37 | public function redirect(string $url = '', int $status = 302, bool $parameter = false) |
38 | 38 | { |
39 | 39 | if (empty($url)) { |
40 | - $url = request()->scheme() . "://" . request()->host(); |
|
40 | + $url = request()->scheme()."://".request()->host(); |
|
41 | 41 | } |
42 | 42 | $param = http_build_query(request()->param()); |
43 | 43 | if ($status == 301) { |
@@ -47,7 +47,7 @@ discard block |
||
47 | 47 | header("Location: {$url}"); |
48 | 48 | } elseif (empty($parameter) == false && empty($param) == true) { |
49 | 49 | header("Location: {$url}"); |
50 | - } else { |
|
50 | + }else { |
|
51 | 51 | header("Location: {$url}?{$param}"); |
52 | 52 | } |
53 | 53 | exit; |
@@ -96,6 +96,6 @@ |
||
96 | 96 | $this->getConfig(); |
97 | 97 | } |
98 | 98 | $client->putObjectFromFile($this->bucket, $object, $filePath); |
99 | - return config('dtapp.baidu.bos.url', '') . $object; |
|
99 | + return config('dtapp.baidu.bos.url', '').$object; |
|
100 | 100 | } |
101 | 101 | } |