| @@ 299-316 (lines=18) @@ | ||
| 296 | /** |
|
| 297 | * {@inheritdoc} |
|
| 298 | */ |
|
| 299 | public function setMetadata($key, $content) |
|
| 300 | { |
|
| 301 | $this->init(); |
|
| 302 | ||
| 303 | try { |
|
| 304 | $this->blobProxy->setBlobMetadata($this->containerName, $key, $content); |
|
| 305 | } catch (ServiceException $e) { |
|
| 306 | $errorCode = $this->getErrorCodeFromServiceException($e); |
|
| 307 | ||
| 308 | throw new \RuntimeException(sprintf( |
|
| 309 | 'Failed to set metadata for blob "%s" in container "%s": %s (%s).', |
|
| 310 | $key, |
|
| 311 | $this->containerName, |
|
| 312 | $e->getErrorText(), |
|
| 313 | $errorCode |
|
| 314 | ), $e->getCode()); |
|
| 315 | } |
|
| 316 | } |
|
| 317 | ||
| 318 | /** |
|
| 319 | * {@inheritdoc} |
|
| @@ 321-340 (lines=20) @@ | ||
| 318 | /** |
|
| 319 | * {@inheritdoc} |
|
| 320 | */ |
|
| 321 | public function getMetadata($key) |
|
| 322 | { |
|
| 323 | $this->init(); |
|
| 324 | ||
| 325 | try { |
|
| 326 | $properties = $this->blobProxy->getBlobProperties($this->containerName, $key); |
|
| 327 | ||
| 328 | return $properties->getMetadata(); |
|
| 329 | } catch (ServiceException $e) { |
|
| 330 | $errorCode = $this->getErrorCodeFromServiceException($e); |
|
| 331 | ||
| 332 | throw new \RuntimeException(sprintf( |
|
| 333 | 'Failed to get metadata for blob "%s" in container "%s": %s (%s).', |
|
| 334 | $key, |
|
| 335 | $this->containerName, |
|
| 336 | $e->getErrorText(), |
|
| 337 | $errorCode |
|
| 338 | ), $e->getCode()); |
|
| 339 | } |
|
| 340 | } |
|
| 341 | ||
| 342 | /** |
|
| 343 | * Lazy initialization, automatically called when some method is called after construction. |
|