Skip to content

Commit

Permalink
Merge pull request #564 from KnpLabs/merge-master-into-1.x
Browse files Browse the repository at this point in the history
Merge master into 1.x
  • Loading branch information
nicolasmure authored Mar 26, 2018
2 parents 34441f0 + 59e3702 commit 8649be2
Show file tree
Hide file tree
Showing 7 changed files with 31 additions and 12 deletions.
12 changes: 12 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,15 @@
v0.6
====

## Changes
- Add support for major release of Azure Blob Storage SDK [#558](https://github.com/KnpLabs/Gaufrette/pull/558)

## Fixes
- Fix Dockerfile for php 7.0 [aaa66dc](https://github.com/KnpLabs/Gaufrette/commit/aaa66dcf298d313e7ae3f525714923fcfd787e94)
- Fix appveyor build [#562](https://github.com/KnpLabs/Gaufrette/pull/562)

Thank you @nicolasmure, @NiR- and @z38 for your contributions!

v0.5
====

Expand Down
3 changes: 1 addition & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,7 @@
"mikey179/vfsStream": "~1.2.0",
"league/flysystem": "~1.0",
"mongodb/mongodb": "^1.1",
"microsoft/windowsazure": "~0.4",
"microsoft/azure-storage": "~0.15.0",
"microsoft/azure-storage-blob": "^1.0",
"akeneo/phpspec-skip-example-extension": "^3.0",
"liuggio/fastest": "^1.6"
},
Expand Down
6 changes: 1 addition & 5 deletions doc/adapters/azure-blob-storage.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,11 @@ currentMenu: azure-blob-storage

# AzureBlobStorage

First, you will need to install the adapter:
Azure Blob Storage is the storage service provided by Microsoft Windows Azure cloud environment. First, you will need to install the adapter:
```bash
composer require gaufrette/azure-blob-storage-adapter
```

Azure Blob Storage is the storage service provided by Microsoft Windows Azure cloud environment. To use this adapter
you need to install the [Azure SDK for php](http://www.windowsazure.com/en-us/develop/php/common-tasks/download-php-sdk/)
into your project.

To instantiate the `AzureBlobStorage` adapter you need a `BlobProxyFactoryInterface` instance (you can use the default
`BlobProxyFactory` class) and a connection string. The connection string should follow this prototype:

Expand Down
8 changes: 7 additions & 1 deletion src/Gaufrette/Adapter/AzureBlobStorage.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
use Gaufrette\Adapter\AzureBlobStorage\BlobProxyFactoryInterface;
use MicrosoftAzure\Storage\Blob\Models\Blob;
use MicrosoftAzure\Storage\Blob\Models\CreateBlobOptions;
use MicrosoftAzure\Storage\Blob\Models\CreateBlockBlobOptions;
use MicrosoftAzure\Storage\Blob\Models\CreateContainerOptions;
use MicrosoftAzure\Storage\Common\Exceptions\ServiceException;

Expand Down Expand Up @@ -181,7 +182,12 @@ public function write($key, $content)
$this->init();
list($containerName, $key) = $this->tokenizeKey($key);

$options = new CreateBlobOptions();
if (class_exists(CreateBlockBlobOptions::class)) {
$options = new CreateBlockBlobOptions();
} else {
// for microsoft/azure-storage < 1.0
$options = new CreateBlobOptions();
}

if ($this->detectContentType) {
$contentType = $this->guessContentType($content);
Expand Down
8 changes: 7 additions & 1 deletion src/Gaufrette/Adapter/AzureBlobStorage/BlobProxyFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

namespace Gaufrette\Adapter\AzureBlobStorage;

use MicrosoftAzure\Storage\Blob\BlobRestProxy;
use MicrosoftAzure\Storage\Common\ServicesBuilder;

/**
Expand Down Expand Up @@ -29,6 +30,11 @@ public function __construct($connectionString)
*/
public function create()
{
return ServicesBuilder::getInstance()->createBlobService($this->connectionString);
if (class_exists(ServicesBuilder::class)) {
// for microsoft/azure-storage < 1.0
return ServicesBuilder::getInstance()->createBlobService($this->connectionString);
} else {
return BlobRestProxy::createBlobService($this->connectionString);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,7 @@ public function shouldKeepFileObjectInRegister()
* @test
* @group functional
*/
public function shouldWrtieToSameFile()
public function shouldWriteToSameFile()
{
$path = $this->createUniqueContainerName('container') . '/somefile';

Expand All @@ -222,7 +222,7 @@ public function shouldWrtieToSameFile()
$FileObjectB = $this->filesystem->createFile($path);
$FileObjectB->setContent('DEF');

$this->assertEquals('DEF', $FileObjectB->getContent());
$this->assertEquals('DEF', $FileObjectA->getContent());
}

private function createUniqueContainerName($prefix)
Expand Down
2 changes: 1 addition & 1 deletion tests/Gaufrette/Functional/Adapter/FunctionalTestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,6 @@ public function shouldWriteToSameFile()
$FileObjectB = $this->filesystem->createFile('somefile');
$FileObjectB->setContent('DEF');

$this->assertEquals('DEF', $FileObjectB->getContent());
$this->assertEquals('DEF', $FileObjectA->getContent());
}
}

0 comments on commit 8649be2

Please sign in to comment.