| @@ 363-381 (lines=19) @@ | ||
| 360 | * @throws \RuntimeException |
|
| 361 | * @throws \InvalidArgumentException |
|
| 362 | */ |
|
| 363 | public function setMetadata($key, $content) |
|
| 364 | { |
|
| 365 | $this->init(); |
|
| 366 | list($containerName, $key) = $this->tokenizeKey($key); |
|
| 367 | ||
| 368 | try { |
|
| 369 | $this->blobProxy->setBlobMetadata($containerName, $key, $content); |
|
| 370 | } catch (ServiceException $e) { |
|
| 371 | $errorCode = $this->getErrorCodeFromServiceException($e); |
|
| 372 | ||
| 373 | throw new \RuntimeException(sprintf( |
|
| 374 | 'Failed to set metadata for blob "%s" in container "%s": %s (%s).', |
|
| 375 | $key, |
|
| 376 | $containerName, |
|
| 377 | $e->getErrorText(), |
|
| 378 | $errorCode |
|
| 379 | ), $e->getCode()); |
|
| 380 | } |
|
| 381 | } |
|
| 382 | ||
| 383 | /** |
|
| 384 | * {@inheritdoc} |
|
| @@ 388-408 (lines=21) @@ | ||
| 385 | * @throws \RuntimeException |
|
| 386 | * @throws \InvalidArgumentException |
|
| 387 | */ |
|
| 388 | public function getMetadata($key) |
|
| 389 | { |
|
| 390 | $this->init(); |
|
| 391 | list($containerName, $key) = $this->tokenizeKey($key); |
|
| 392 | ||
| 393 | try { |
|
| 394 | $properties = $this->blobProxy->getBlobProperties($containerName, $key); |
|
| 395 | ||
| 396 | return $properties->getMetadata(); |
|
| 397 | } catch (ServiceException $e) { |
|
| 398 | $errorCode = $this->getErrorCodeFromServiceException($e); |
|
| 399 | ||
| 400 | throw new \RuntimeException(sprintf( |
|
| 401 | 'Failed to get metadata for blob "%s" in container "%s": %s (%s).', |
|
| 402 | $key, |
|
| 403 | $containerName, |
|
| 404 | $e->getErrorText(), |
|
| 405 | $errorCode |
|
| 406 | ), $e->getCode()); |
|
| 407 | } |
|
| 408 | } |
|
| 409 | ||
| 410 | /** |
|
| 411 | * Lazy initialization, automatically called when some method is called after construction. |
|