@@ -31,7 +31,7 @@ discard block |
||
31 | 31 | 'accept' => 'json' |
32 | 32 | ); |
33 | 33 | |
34 | - $url = $this->url . '/pretreatment'; |
|
34 | + $url = $this->url.'/pretreatment'; |
|
35 | 35 | $signature = Signature::getSignature($this->config, $params, Signature::SIGN_VIDEO); |
36 | 36 | $response = $client->request('POST', $url, [ |
37 | 37 | 'headers' => array('Authorization' => "UPYUN {$this->config->operatorName}:$signature"), |
@@ -53,7 +53,7 @@ discard block |
||
53 | 53 | 'task_ids' => implode(',', $taskIds) |
54 | 54 | ); |
55 | 55 | |
56 | - $url = $this->url . $path; |
|
56 | + $url = $this->url.$path; |
|
57 | 57 | $signature = Signature::getSignature($this->config, $params, Signature::SIGN_VIDEO); |
58 | 58 | $response = $client->request('GET', $url, [ |
59 | 59 | 'headers' => array('Authorization' => "UPYUN {$this->config->operatorName}:$signature"), |
@@ -17,7 +17,7 @@ discard block |
||
17 | 17 | |
18 | 18 | public function __construct(Config $config) { |
19 | 19 | $this->config = $config; |
20 | - $this->url = ($this->config->useSsl ? 'https://' : 'http://') . Config::ED_FORM . '/'. |
|
20 | + $this->url = ($this->config->useSsl ? 'https://' : 'http://').Config::ED_FORM.'/'. |
|
21 | 21 | $this->config->bucketName; |
22 | 22 | } |
23 | 23 | |
@@ -31,20 +31,20 @@ discard block |
||
31 | 31 | * @throws \Exception |
32 | 32 | */ |
33 | 33 | public function upload($path, $stream, $fileHash, $params = []) { |
34 | - $path = '/' . ltrim($path, '/'); |
|
34 | + $path = '/'.ltrim($path, '/'); |
|
35 | 35 | $initInfo = $this->initRequest($path, $stream, $fileHash, $params); |
36 | 36 | $blockStatus = $initInfo->status; |
37 | 37 | |
38 | 38 | $newBlockStatus = $blockStatus; |
39 | 39 | |
40 | - for($blockId = 0; $blockId < $initInfo->blocks; $blockId++) { |
|
41 | - if($blockStatus[$blockId] === 0) { |
|
40 | + for ($blockId = 0; $blockId < $initInfo->blocks; $blockId++) { |
|
41 | + if ($blockStatus[$blockId] === 0) { |
|
42 | 42 | $return = $this->blockUpload($initInfo, $blockId, $stream); |
43 | 43 | $newBlockStatus = $return->status; |
44 | 44 | } |
45 | 45 | } |
46 | 46 | |
47 | - if(array_sum($newBlockStatus) === $initInfo->blocks) { |
|
47 | + if (array_sum($newBlockStatus) === $initInfo->blocks) { |
|
48 | 48 | return $this->endRequest($initInfo, $params); |
49 | 49 | } else { |
50 | 50 | throw new \Exception(sprintf("chunk upload failed! current every block status is : [%s]", implode(',', $newBlockStatus))); |
@@ -102,13 +102,13 @@ discard block |
||
102 | 102 | ); |
103 | 103 | |
104 | 104 | $multipart = []; |
105 | - foreach($postData as $key => $value) { |
|
105 | + foreach ($postData as $key => $value) { |
|
106 | 106 | $multipart[] = ['name' => $key, 'contents' => $value]; |
107 | 107 | } |
108 | 108 | $multipart[] = [ |
109 | 109 | 'name' => 'file', |
110 | 110 | 'contents' => $fileBlock, |
111 | - 'filename' => 'file', //this value must be file |
|
111 | + 'filename' => 'file', //this value must be file |
|
112 | 112 | 'headers' => ['Content-Type' => 'application/octet-stream'] |
113 | 113 | ]; |
114 | 114 | $postData['file'] = $fileBlock; |
@@ -26,12 +26,12 @@ discard block |
||
26 | 26 | |
27 | 27 | public function __construct(Config $config) { |
28 | 28 | $this->config = $config; |
29 | - $this->endpoint = Config::$restApiEndPoint . '/' . $config->bucketName; |
|
29 | + $this->endpoint = Config::$restApiEndPoint.'/'.$config->bucketName; |
|
30 | 30 | } |
31 | 31 | |
32 | 32 | public function request($method, $storagePath) { |
33 | 33 | $this->method = strtoupper($method); |
34 | - $this->storagePath = '/' . ltrim($storagePath, '/'); |
|
34 | + $this->storagePath = '/'.ltrim($storagePath, '/'); |
|
35 | 35 | return $this; |
36 | 36 | } |
37 | 37 | |
@@ -56,10 +56,10 @@ discard block |
||
56 | 56 | 'timeout' => $this->config->timeout, |
57 | 57 | ]); |
58 | 58 | |
59 | - $url = ($this->config->useSsl ? 'https://' : 'http://') . $this->endpoint . $this->storagePath; |
|
59 | + $url = ($this->config->useSsl ? 'https://' : 'http://').$this->endpoint.$this->storagePath; |
|
60 | 60 | $bodySize = 0; |
61 | 61 | $body = null; |
62 | - if($this->file && $this->method === 'PUT') { |
|
62 | + if ($this->file && $this->method === 'PUT') { |
|
63 | 63 | $bodySize = $this->file->getSize(); |
64 | 64 | $body = $this->file; |
65 | 65 | } |
@@ -81,7 +81,7 @@ discard block |
||
81 | 81 | } |
82 | 82 | |
83 | 83 | public function withHeaders($headers) { |
84 | - if(is_array($headers)) { |
|
84 | + if (is_array($headers)) { |
|
85 | 85 | foreach ($headers as $header => $value) { |
86 | 86 | $this->withHeader($header, $value); |
87 | 87 | } |
@@ -5,7 +5,7 @@ discard block |
||
5 | 5 | use Upyun\Signature; |
6 | 6 | use GuzzleHttp\Client; |
7 | 7 | |
8 | -class Form extends Rest{ |
|
8 | +class Form extends Rest { |
|
9 | 9 | |
10 | 10 | public function upload($path, $stream, $params) { |
11 | 11 | $params['save-key'] = $path; |
@@ -21,7 +21,7 @@ discard block |
||
21 | 21 | 'timeout' => $this->config->timeout, |
22 | 22 | ]); |
23 | 23 | |
24 | - $url = ($this->config->useSsl ? 'https://' : 'http://') . $this->endpoint; |
|
24 | + $url = ($this->config->useSsl ? 'https://' : 'http://').$this->endpoint; |
|
25 | 25 | |
26 | 26 | $response = $client->request('POST', $url, array( |
27 | 27 | 'multipart' => array( |
@@ -3,7 +3,7 @@ discard block |
||
3 | 3 | class Util { |
4 | 4 | |
5 | 5 | public static function trim($str) { |
6 | - if(is_array($str)) { |
|
6 | + if (is_array($str)) { |
|
7 | 7 | return array_map(array('Util', 'trim'), $str); |
8 | 8 | } else { |
9 | 9 | return trim($str); |
@@ -14,7 +14,7 @@ discard block |
||
14 | 14 | $params = []; |
15 | 15 | foreach ($headers as $header => $value) { |
16 | 16 | $header = strtolower($header); |
17 | - if(strpos($header, 'x-upyun-') !== false) { |
|
17 | + if (strpos($header, 'x-upyun-') !== false) { |
|
18 | 18 | $params[$header] = $value[0]; |
19 | 19 | } |
20 | 20 | } |
@@ -23,12 +23,12 @@ discard block |
||
23 | 23 | |
24 | 24 | public static function parseDir($body) { |
25 | 25 | $files = array(); |
26 | - if(!$body) { |
|
26 | + if (!$body) { |
|
27 | 27 | return array('files' => $files, 'is_end' => true); |
28 | 28 | } |
29 | 29 | |
30 | 30 | $lines = explode("\n", $body); |
31 | - foreach($lines as $line) { |
|
31 | + foreach ($lines as $line) { |
|
32 | 32 | $file = []; |
33 | 33 | list($file['name'], $file['type'], $file['size'], $file['time']) = explode("\t", $line, 4); |
34 | 34 | $files[] = $file; |