@@ -36,9 +36,9 @@ |
||
| 36 | 36 | if (! $useBlock) { |
| 37 | 37 | $req = new Rest($this->config); |
| 38 | 38 | return $req->request('PUT', $path) |
| 39 | - ->withHeaders($params) |
|
| 40 | - ->withFile($stream) |
|
| 41 | - ->send(); |
|
| 39 | + ->withHeaders($params) |
|
| 40 | + ->withFile($stream) |
|
| 41 | + ->send(); |
|
| 42 | 42 | } elseif ($this->config->uploadType === 'BLOCK_PARALLEL') { |
| 43 | 43 | return $this->concurrentPointUpload($path, $stream, $params); |
| 44 | 44 | } else { |
@@ -22,6 +22,11 @@ discard block |
||
| 22 | 22 | $this->config = $config; |
| 23 | 23 | } |
| 24 | 24 | |
| 25 | + /** |
|
| 26 | + * @param string $path |
|
| 27 | + * @param string $file |
|
| 28 | + * @param boolean $withAsyncProcess |
|
| 29 | + */ |
|
| 25 | 30 | public function upload($path, $file, $params, $withAsyncProcess) |
| 26 | 31 | { |
| 27 | 32 | $stream = Psr7\stream_for($file); |
@@ -49,10 +54,10 @@ discard block |
||
| 49 | 54 | /** |
| 50 | 55 | * 串行式断点续传 |
| 51 | 56 | * @param $path |
| 52 | - * @param $stream |
|
| 57 | + * @param \Psr\Http\Message\StreamInterface $stream |
|
| 53 | 58 | * @param $params |
| 54 | 59 | * |
| 55 | - * @return mixed|\Psr\Http\Message\ResponseInterface |
|
| 60 | + * @return \Psr\Http\Message\ResponseInterface |
|
| 56 | 61 | * @throws \Exception |
| 57 | 62 | */ |
| 58 | 63 | private function pointUpload($path, $stream, $params) |
@@ -110,6 +115,9 @@ discard block |
||
| 110 | 115 | return $res; |
| 111 | 116 | } |
| 112 | 117 | |
| 118 | + /** |
|
| 119 | + * @param integer|null $fileSize |
|
| 120 | + */ |
|
| 113 | 121 | private function needUseBlock($fileSize) |
| 114 | 122 | { |
| 115 | 123 | if ($this->config->uploadType === 'BLOCK' || |
@@ -126,10 +134,10 @@ discard block |
||
| 126 | 134 | /** |
| 127 | 135 | * 并行式断点续传 |
| 128 | 136 | * @param $path |
| 129 | - * @param $stream |
|
| 137 | + * @param \Psr\Http\Message\StreamInterface $stream |
|
| 130 | 138 | * @param $params |
| 131 | 139 | * |
| 132 | - * @return mixed|\Psr\Http\Message\ResponseInterface |
|
| 140 | + * @return \Psr\Http\Message\ResponseInterface |
|
| 133 | 141 | * @throws \Exception |
| 134 | 142 | */ |
| 135 | 143 | private function concurrentPointUpload($path, $stream, $params) |
@@ -32,6 +32,9 @@ discard block |
||
| 32 | 32 | $this->endpoint = $config->getProtocol() . Config::$restApiEndPoint . '/' . $config->serviceName; |
| 33 | 33 | } |
| 34 | 34 | |
| 35 | + /** |
|
| 36 | + * @param string $method |
|
| 37 | + */ |
|
| 35 | 38 | public function request($method, $storagePath) |
| 36 | 39 | { |
| 37 | 40 | $this->method = strtoupper($method); |
@@ -41,7 +44,7 @@ discard block |
||
| 41 | 44 | |
| 42 | 45 | |
| 43 | 46 | /** |
| 44 | - * @param string|resource $file |
|
| 47 | + * @param \Psr\Http\Message\StreamInterface $file |
|
| 45 | 48 | * |
| 46 | 49 | * @return $this |
| 47 | 50 | */ |
@@ -54,7 +57,7 @@ discard block |
||
| 54 | 57 | } |
| 55 | 58 | |
| 56 | 59 | /** |
| 57 | - * @return mixed|\Psr\Http\Message\ResponseInterface |
|
| 60 | + * @return \Psr\Http\Message\ResponseInterface |
|
| 58 | 61 | */ |
| 59 | 62 | public function send() |
| 60 | 63 | { |
@@ -197,7 +197,7 @@ discard block |
||
| 197 | 197 | * 获取云存储文件/目录的基本信息 |
| 198 | 198 | * |
| 199 | 199 | * @param string $path 云存储的文件路径 |
| 200 | - * @param array $otherHeaders 设置了后,方法将返回其他 http header 中的信息,默认为空 |
|
| 200 | + * @param string[] $otherHeaders 设置了后,方法将返回其他 http header 中的信息,默认为空 |
|
| 201 | 201 | * |
| 202 | 202 | * @return array 返回一个数组,默认包含以下 key |
| 203 | 203 | * - `x-upyun-file-type` 当 $path 是目录时,值为 *folder*,当 $path 是文件时,值为 *file*, |
@@ -333,7 +333,7 @@ discard block |
||
| 333 | 333 | /** |
| 334 | 334 | * 刷新缓存 |
| 335 | 335 | * |
| 336 | - * @param array|string $urls 需要刷新的文件 url 列表 |
|
| 336 | + * @param string $urls 需要刷新的文件 url 列表 |
|
| 337 | 337 | * |
| 338 | 338 | * @return array 刷新失败的 url 列表,若全部刷新成功则为空数组 |
| 339 | 339 | */ |