| @@ 101-120 (lines=20) @@ | ||
| 98 | * |
|
| 99 | * @return bool |
|
| 100 | */ |
|
| 101 | public function writeStream($path, $resource, Config $config) |
|
| 102 | { |
|
| 103 | $uri = stream_get_meta_data($resource)['uri']; |
|
| 104 | ||
| 105 | try { |
|
| 106 | $response = $this->normalizeResponse( |
|
| 107 | Cosapi::upload($this->getBucket(), $uri, $path) |
|
| 108 | ); |
|
| 109 | ||
| 110 | $this->setContentType($path, stream_get_contents($resource)); |
|
| 111 | } catch (RuntimeException $exception) { |
|
| 112 | if ($exception->getCode() == -4018) { |
|
| 113 | return $this->getMetadata($path); |
|
| 114 | } |
|
| 115 | ||
| 116 | throw $exception; |
|
| 117 | } |
|
| 118 | ||
| 119 | return $response; |
|
| 120 | } |
|
| 121 | ||
| 122 | /** |
|
| 123 | * @param string $path |
|
| @@ 161-180 (lines=20) @@ | ||
| 158 | * |
|
| 159 | * @return bool |
|
| 160 | */ |
|
| 161 | public function updateStream($path, $resource, Config $config) |
|
| 162 | { |
|
| 163 | $uri = stream_get_meta_data($resource)['uri']; |
|
| 164 | ||
| 165 | try { |
|
| 166 | $response = $this->normalizeResponse( |
|
| 167 | Cosapi::upload($this->getBucket(), $uri, $path, null, null, 0) |
|
| 168 | ); |
|
| 169 | ||
| 170 | $this->setContentType($path, stream_get_contents($resource)); |
|
| 171 | } catch (RuntimeException $exception) { |
|
| 172 | if ($exception->getCode() == -4018) { |
|
| 173 | return $this->getMetadata($path); |
|
| 174 | } |
|
| 175 | ||
| 176 | throw $exception; |
|
| 177 | } |
|
| 178 | ||
| 179 | return $response; |
|
| 180 | } |
|
| 181 | ||
| 182 | /** |
|
| 183 | * @param string $path |
|