@@ 436-454 (lines=19) @@ | ||
433 | * @throws \RuntimeException |
|
434 | * @throws \InvalidArgumentException |
|
435 | */ |
|
436 | public function setMetadata($key, $content) |
|
437 | { |
|
438 | $this->init(); |
|
439 | list($containerName, $key) = $this->tokenizeKey($key); |
|
440 | ||
441 | try { |
|
442 | $this->blobProxy->setBlobMetadata($containerName, $key, $content); |
|
443 | } catch (ServiceException $e) { |
|
444 | $errorCode = $this->getErrorCodeFromServiceException($e); |
|
445 | ||
446 | throw new \RuntimeException(sprintf( |
|
447 | 'Failed to set metadata for blob "%s" in container "%s": %s (%s).', |
|
448 | $key, |
|
449 | $containerName, |
|
450 | $e->getErrorText(), |
|
451 | $errorCode |
|
452 | ), $e->getCode()); |
|
453 | } |
|
454 | } |
|
455 | ||
456 | /** |
|
457 | * {@inheritdoc} |
|
@@ 461-481 (lines=21) @@ | ||
458 | * @throws \RuntimeException |
|
459 | * @throws \InvalidArgumentException |
|
460 | */ |
|
461 | public function getMetadata($key) |
|
462 | { |
|
463 | $this->init(); |
|
464 | list($containerName, $key) = $this->tokenizeKey($key); |
|
465 | ||
466 | try { |
|
467 | $properties = $this->blobProxy->getBlobProperties($containerName, $key); |
|
468 | ||
469 | return $properties->getMetadata(); |
|
470 | } catch (ServiceException $e) { |
|
471 | $errorCode = $this->getErrorCodeFromServiceException($e); |
|
472 | ||
473 | throw new \RuntimeException(sprintf( |
|
474 | 'Failed to get metadata for blob "%s" in container "%s": %s (%s).', |
|
475 | $key, |
|
476 | $containerName, |
|
477 | $e->getErrorText(), |
|
478 | $errorCode |
|
479 | ), $e->getCode()); |
|
480 | } |
|
481 | } |
|
482 | ||
483 | /** |
|
484 | * Lazy initialization, automatically called when some method is called after construction. |