forked from KnpLabs/Gaufrette
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added support for calculated size for Azure Blob Storage
- Loading branch information
1 parent
3dd9fcc
commit 6fd9bdd
Showing
2 changed files
with
36 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -20,7 +20,9 @@ | |
* @author Paweł Czyżewski <[email protected]> | ||
*/ | ||
class AzureBlobStorage implements Adapter, | ||
MetadataSupporter | ||
MetadataSupporter, | ||
SizeCalculator | ||
|
||
{ | ||
/** | ||
* Error constants. | ||
|
@@ -306,6 +308,26 @@ public function mtime($key) | |
} | ||
} | ||
|
||
/** | ||
* {@inheritdoc} | ||
*/ | ||
public function size($key) | ||
{ | ||
$this->init(); | ||
list($containerName, $key) = $this->tokenizeKey($key); | ||
|
||
try { | ||
$properties = $this->blobProxy->getBlobProperties($containerName, $key); | ||
|
||
return $properties->getProperties()->getContentLength(); | ||
} catch (ServiceException $e) { | ||
$this->failIfContainerNotFound($e, sprintf('read content length for key "%s"', $key), $containerName); | ||
|
||
return false; | ||
} | ||
|
||
} | ||
|
||
/** | ||
* {@inheritdoc} | ||
* @throws \RuntimeException | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters