| @@ 189-202 (lines=14) @@ | ||
| 186 | /** |
|
| 187 | * {@inheritdoc} |
|
| 188 | */ |
|
| 189 | public function mtime($key) |
|
| 190 | { |
|
| 191 | try { |
|
| 192 | $result = $this->service->headObject($this->getOptions($key)); |
|
| 193 | ||
| 194 | return strtotime($result['LastModified']); |
|
| 195 | } catch (\Exception $e) { |
|
| 196 | if ($e instanceof S3Exception && $e->getResponse()->getStatusCode() === 404) { |
|
| 197 | throw new FileNotFound($key); |
|
| 198 | } |
|
| 199 | ||
| 200 | throw StorageFailure::unexpectedFailure('mtime', ['key' => $key], $e); |
|
| 201 | } |
|
| 202 | } |
|
| 203 | ||
| 204 | /** |
|
| 205 | * {@inheritdoc} |
|
| @@ 207-220 (lines=14) @@ | ||
| 204 | /** |
|
| 205 | * {@inheritdoc} |
|
| 206 | */ |
|
| 207 | public function size($key) |
|
| 208 | { |
|
| 209 | try { |
|
| 210 | $result = $this->service->headObject($this->getOptions($key)); |
|
| 211 | ||
| 212 | return $result['ContentLength']; |
|
| 213 | } catch (\Exception $e) { |
|
| 214 | if ($e instanceof S3Exception && $e->getResponse()->getStatusCode() === 404) { |
|
| 215 | throw new FileNotFound($key); |
|
| 216 | } |
|
| 217 | ||
| 218 | throw StorageFailure::unexpectedFailure('size', ['key' => $key], $e); |
|
| 219 | } |
|
| 220 | } |
|
| 221 | ||
| 222 | /** |
|
| 223 | * {@inheritdoc} |
|
| @@ 259-272 (lines=14) @@ | ||
| 256 | /** |
|
| 257 | * {@inheritdoc} |
|
| 258 | */ |
|
| 259 | public function delete($key) |
|
| 260 | { |
|
| 261 | try { |
|
| 262 | $this->service->deleteObject($this->getOptions($key)); |
|
| 263 | ||
| 264 | return true; |
|
| 265 | } catch (\Exception $e) { |
|
| 266 | if ($e instanceof S3Exception && $e->getResponse()->getStatusCode() === 404) { |
|
| 267 | throw new FileNotFound($key); |
|
| 268 | } |
|
| 269 | ||
| 270 | throw StorageFailure::unexpectedFailure('delete', ['key' => $key], $e); |
|
| 271 | } |
|
| 272 | } |
|
| 273 | ||
| 274 | /** |
|
| 275 | * {@inheritdoc} |
|
| @@ 380-392 (lines=13) @@ | ||
| 377 | return $fileInfo->buffer($content); |
|
| 378 | } |
|
| 379 | ||
| 380 | public function mimeType($key) |
|
| 381 | { |
|
| 382 | try { |
|
| 383 | $result = $this->service->headObject($this->getOptions($key)); |
|
| 384 | return ($result['ContentType']); |
|
| 385 | } catch (\Exception $e) { |
|
| 386 | if ($e instanceof S3Exception && $e->getResponse()->getStatusCode() === 404) { |
|
| 387 | throw new FileNotFound($key); |
|
| 388 | } |
|
| 389 | ||
| 390 | throw StorageFailure::unexpectedFailure('mimeType', ['key' => $key], $e); |
|
| 391 | } |
|
| 392 | } |
|
| 393 | } |
|
| 394 | ||