/** * @param \Gaufrette\Adapter\AzureBlobStorage\BlobProxyFactoryInterface $blobProxyFactory * @param \WindowsAzure\Blob\Internal\IBlob $blobProxy */ public function it_should_rename_file($blobProxyFactory, $blobProxy) { $blobProxy->copyBlob('containerName', 'filename2', 'containerName', 'filename1')->shouldBeCalled(); $blobProxy->deleteBlob('containerName', 'filename1')->shouldBeCalled(); $blobProxyFactory->create()->shouldBeCalled()->willReturn($blobProxy); $this->rename('filename1', 'filename2')->shouldReturn(true); }
/** * {@inheritDoc} */ public function rename($sourceKey, $targetKey) { $this->init(); try { $this->blobProxy->copyBlob($this->containerName, $targetKey, $this->containerName, $sourceKey); $this->blobProxy->deleteBlob($this->containerName, $sourceKey); return true; } catch (ServiceException $e) { $this->failIfContainerNotFound($e, sprintf('rename key "%s"', $sourceKey)); return false; } }
/** * @inheritdoc */ public function deleteDir($dirname) { $options = new ListBlobsOptions(); $options->setPrefix($dirname); /** @var ListBlobsResult $listResults */ $listResults = $this->client->listBlobs($this->container, $options); foreach ($listResults->getBlobs() as $blob) { /** @var Blob $blob */ $this->client->deleteBlob($this->container, $blob->getName()); } return true; }