| @@ 78-90 (lines=13) @@ | ||
| 75 | /** |
|
| 76 | * {@inheritdoc} |
|
| 77 | */ |
|
| 78 | public function copy($path, $newpath): bool |
|
| 79 | { |
|
| 80 | $path = $this->applyPathPrefix($path); |
|
| 81 | $newpath = $this->applyPathPrefix($newpath); |
|
| 82 | ||
| 83 | try { |
|
| 84 | $this->client->copy($path, $newpath); |
|
| 85 | } catch (BadRequest $e) { |
|
| 86 | return false; |
|
| 87 | } |
|
| 88 | ||
| 89 | return true; |
|
| 90 | } |
|
| 91 | ||
| 92 | /** |
|
| 93 | * {@inheritdoc} |
|
| @@ 119-130 (lines=12) @@ | ||
| 116 | /** |
|
| 117 | * {@inheritdoc} |
|
| 118 | */ |
|
| 119 | public function createDir($dirname, Config $config) |
|
| 120 | { |
|
| 121 | $path = $this->applyPathPrefix($dirname); |
|
| 122 | ||
| 123 | try { |
|
| 124 | $object = $this->client->createFolder($path); |
|
| 125 | } catch (BadRequest $e) { |
|
| 126 | return false; |
|
| 127 | } |
|
| 128 | ||
| 129 | return $this->normalizeResponse($object); |
|
| 130 | } |
|
| 131 | ||
| 132 | /** |
|
| 133 | * {@inheritdoc} |
|
| @@ 159-170 (lines=12) @@ | ||
| 156 | /** |
|
| 157 | * {@inheritdoc} |
|
| 158 | */ |
|
| 159 | public function readStream($path) |
|
| 160 | { |
|
| 161 | $path = $this->applyPathPrefix($path); |
|
| 162 | ||
| 163 | try { |
|
| 164 | $stream = $this->client->download($path); |
|
| 165 | } catch (BadRequest $e) { |
|
| 166 | return false; |
|
| 167 | } |
|
| 168 | ||
| 169 | return compact('stream'); |
|
| 170 | } |
|
| 171 | ||
| 172 | /** |
|
| 173 | * {@inheritdoc} |
|
| @@ 205-216 (lines=12) @@ | ||
| 202 | /** |
|
| 203 | * {@inheritdoc} |
|
| 204 | */ |
|
| 205 | public function getMetadata($path) |
|
| 206 | { |
|
| 207 | $path = $this->applyPathPrefix($path); |
|
| 208 | ||
| 209 | try { |
|
| 210 | $object = $this->client->getMetadata($path); |
|
| 211 | } catch (BadRequest $e) { |
|
| 212 | return false; |
|
| 213 | } |
|
| 214 | ||
| 215 | return $this->normalizeResponse($object); |
|
| 216 | } |
|
| 217 | ||
| 218 | /** |
|
| 219 | * {@inheritdoc} |
|
| @@ 274-285 (lines=12) @@ | ||
| 271 | * |
|
| 272 | * @return array|false file metadata |
|
| 273 | */ |
|
| 274 | protected function upload(string $path, $contents, string $mode) |
|
| 275 | { |
|
| 276 | $path = $this->applyPathPrefix($path); |
|
| 277 | ||
| 278 | try { |
|
| 279 | $object = $this->client->upload($path, $contents, $mode); |
|
| 280 | } catch (BadRequest $e) { |
|
| 281 | return false; |
|
| 282 | } |
|
| 283 | ||
| 284 | return $this->normalizeResponse($object); |
|
| 285 | } |
|
| 286 | ||
| 287 | protected function normalizeResponse(array $response): array |
|
| 288 | { |
|