| @@ 166-180 (lines=15) @@ | ||
| 163 | * @throws \RuntimeException |
|
| 164 | * @throws \InvalidArgumentException |
|
| 165 | */ |
|
| 166 | public function read($key) |
|
| 167 | { |
|
| 168 | $this->init(); |
|
| 169 | list($containerName, $key) = $this->tokenizeKey($key); |
|
| 170 | ||
| 171 | try { |
|
| 172 | $blob = $this->blobProxy->getBlob($containerName, $key); |
|
| 173 | ||
| 174 | return stream_get_contents($blob->getContentStream()); |
|
| 175 | } catch (ServiceException $e) { |
|
| 176 | $this->failIfContainerNotFound($e, sprintf('read key "%s"', $key), $containerName); |
|
| 177 | ||
| 178 | return false; |
|
| 179 | } |
|
| 180 | } |
|
| 181 | ||
| 182 | /** |
|
| 183 | * {@inheritdoc} |
|
| @@ 302-316 (lines=15) @@ | ||
| 299 | * @throws \RuntimeException |
|
| 300 | * @throws \InvalidArgumentException |
|
| 301 | */ |
|
| 302 | public function mtime($key) |
|
| 303 | { |
|
| 304 | $this->init(); |
|
| 305 | list($containerName, $key) = $this->tokenizeKey($key); |
|
| 306 | ||
| 307 | try { |
|
| 308 | $properties = $this->blobProxy->getBlobProperties($containerName, $key); |
|
| 309 | ||
| 310 | return $properties->getProperties()->getLastModified()->getTimestamp(); |
|
| 311 | } catch (ServiceException $e) { |
|
| 312 | $this->failIfContainerNotFound($e, sprintf('read mtime for key "%s"', $key), $containerName); |
|
| 313 | ||
| 314 | return false; |
|
| 315 | } |
|
| 316 | } |
|
| 317 | ||
| 318 | /** |
|
| 319 | * {@inheritdoc} |
|
| @@ 321-336 (lines=16) @@ | ||
| 318 | /** |
|
| 319 | * {@inheritdoc} |
|
| 320 | */ |
|
| 321 | public function size($key) |
|
| 322 | { |
|
| 323 | $this->init(); |
|
| 324 | list($containerName, $key) = $this->tokenizeKey($key); |
|
| 325 | ||
| 326 | try { |
|
| 327 | $properties = $this->blobProxy->getBlobProperties($containerName, $key); |
|
| 328 | ||
| 329 | return $properties->getProperties()->getContentLength(); |
|
| 330 | } catch (ServiceException $e) { |
|
| 331 | $this->failIfContainerNotFound($e, sprintf('read content length for key "%s"', $key), $containerName); |
|
| 332 | ||
| 333 | return false; |
|
| 334 | } |
|
| 335 | ||
| 336 | } |
|
| 337 | ||
| 338 | /** |
|
| 339 | * {@inheritdoc} |
|
| @@ 363-377 (lines=15) @@ | ||
| 360 | * @throws \RuntimeException |
|
| 361 | * @throws \InvalidArgumentException |
|
| 362 | */ |
|
| 363 | public function delete($key) |
|
| 364 | { |
|
| 365 | $this->init(); |
|
| 366 | list($containerName, $key) = $this->tokenizeKey($key); |
|
| 367 | ||
| 368 | try { |
|
| 369 | $this->blobProxy->deleteBlob($containerName, $key); |
|
| 370 | ||
| 371 | return true; |
|
| 372 | } catch (ServiceException $e) { |
|
| 373 | $this->failIfContainerNotFound($e, sprintf('delete key "%s"', $key), $containerName); |
|
| 374 | ||
| 375 | return false; |
|
| 376 | } |
|
| 377 | } |
|
| 378 | ||
| 379 | /** |
|
| 380 | * {@inheritdoc} |
|