| @@ 420-438 (lines=19) @@ | ||
| 417 | * @throws \RuntimeException |
|
| 418 | * @throws \InvalidArgumentException |
|
| 419 | */ |
|
| 420 | public function setMetadata($key, $content) |
|
| 421 | { |
|
| 422 | $this->init(); |
|
| 423 | list($containerName, $key) = $this->tokenizeKey($key); |
|
| 424 | ||
| 425 | try { |
|
| 426 | $this->blobProxy->setBlobMetadata($containerName, $key, $content); |
|
| 427 | } catch (ServiceException $e) { |
|
| 428 | $errorCode = $this->getErrorCodeFromServiceException($e); |
|
| 429 | ||
| 430 | throw new \RuntimeException(sprintf( |
|
| 431 | 'Failed to set metadata for blob "%s" in container "%s": %s (%s).', |
|
| 432 | $key, |
|
| 433 | $containerName, |
|
| 434 | $e->getErrorText(), |
|
| 435 | $errorCode |
|
| 436 | ), $e->getCode()); |
|
| 437 | } |
|
| 438 | } |
|
| 439 | ||
| 440 | /** |
|
| 441 | * {@inheritdoc} |
|
| @@ 445-465 (lines=21) @@ | ||
| 442 | * @throws \RuntimeException |
|
| 443 | * @throws \InvalidArgumentException |
|
| 444 | */ |
|
| 445 | public function getMetadata($key) |
|
| 446 | { |
|
| 447 | $this->init(); |
|
| 448 | list($containerName, $key) = $this->tokenizeKey($key); |
|
| 449 | ||
| 450 | try { |
|
| 451 | $properties = $this->blobProxy->getBlobProperties($containerName, $key); |
|
| 452 | ||
| 453 | return $properties->getMetadata(); |
|
| 454 | } catch (ServiceException $e) { |
|
| 455 | $errorCode = $this->getErrorCodeFromServiceException($e); |
|
| 456 | ||
| 457 | throw new \RuntimeException(sprintf( |
|
| 458 | 'Failed to get metadata for blob "%s" in container "%s": %s (%s).', |
|
| 459 | $key, |
|
| 460 | $containerName, |
|
| 461 | $e->getErrorText(), |
|
| 462 | $errorCode |
|
| 463 | ), $e->getCode()); |
|
| 464 | } |
|
| 465 | } |
|
| 466 | ||
| 467 | /** |
|
| 468 | * Lazy initialization, automatically called when some method is called after construction. |
|