Skip to content

Commit

Permalink
Added support for calculated size for Azure Blob Storage
Browse files Browse the repository at this point in the history
  • Loading branch information
gerkestam2 committed Aug 15, 2017
1 parent 3dd9fcc commit 6fd9bdd
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 1 deletion.
24 changes: 23 additions & 1 deletion src/Gaufrette/Adapter/AzureBlobStorage.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,9 @@
* @author Paweł Czyżewski <[email protected]>
*/
class AzureBlobStorage implements Adapter,
MetadataSupporter
MetadataSupporter,
SizeCalculator

{
/**
* Error constants.
Expand Down Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,19 @@ public function shouldGetMtime()
$this->assertGreaterThan(0, $this->filesystem->mtime($path));
}

/**
* @test
* @group functional
*/
public function shouldGetSize()
{
$path = $this->createUniqueContainerName('container') . '/foo';

$this->filesystem->write($path, 'Some content');

$this->assertGreaterThan(11, $this->filesystem->size($path));
}

/**
* @test
* @group functional
Expand Down

0 comments on commit 6fd9bdd

Please sign in to comment.