-
Notifications
You must be signed in to change notification settings - Fork 356
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #313 from Karisch/feature/google-cloud-storage
Add support for Google Cloud Storage
- Loading branch information
Showing
7 changed files
with
546 additions
and
3 deletions.
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 |
---|---|---|
|
@@ -217,6 +217,45 @@ $adapter = new Gaufrette\Adapter\AzureBlobStorage($factory, 'my-container'); | |
$filesystem = new Gaufrette\Filesystem($adapter); | ||
``` | ||
|
||
Using GoogleCloudStorage | ||
------------------------ | ||
|
||
To use the GoogleCloudStorage adapter you will need to create a connection using the [Google APIs Client Library for PHP] | ||
(https://github.com/google/google-api-php-client) and create a Client ID/Service Account in your [Developers Console] | ||
(https://console.developers.google.com/). You can then create the `\Google_Service_Storage` which is required for the | ||
GoogleCloudStorage adapter. | ||
|
||
```php | ||
<?php | ||
|
||
use Gaufrette\Filesystem; | ||
use Gaufrette\Adapter\GoogleCloudStorage; | ||
|
||
$client_id = 'xxxxxxxxxxxxxxx.apps.googleusercontent.com'; | ||
$service_account_name = '[email protected]'; | ||
$key_file_location = 'key.p12'; | ||
$bucket_name = 'mybucket'; | ||
|
||
$client = new \Google_Client(); | ||
$client->setApplicationName('Gaufrette'); | ||
|
||
$key = file_get_contents($key_file_location); | ||
$cred = new \Google_Auth_AssertionCredentials( | ||
$service_account_name, | ||
array(\Google_Service_Storage::DEVSTORAGE_FULL_CONTROL), | ||
$key | ||
); | ||
$client->setAssertionCredentials($cred); | ||
if ($client->getAuth()->isAccessTokenExpired()) { | ||
$client->getAuth()->refreshTokenWithAssertion($cred); | ||
} | ||
|
||
$service = new \Google_Service_Storage($client); | ||
$adapter = new GoogleCloudStorage($service, $bucket_name, array(), true); | ||
|
||
$filesystem = new Filesystem($adapter); | ||
``` | ||
|
||
Using FTP adapters | ||
--------------- | ||
|
||
|
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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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 |
---|---|---|
@@ -0,0 +1,28 @@ | ||
<?php | ||
|
||
namespace spec\Gaufrette\Adapter; | ||
|
||
use PhpSpec\ObjectBehavior; | ||
|
||
class GoogleCloudStorageSpec extends ObjectBehavior | ||
{ | ||
public function let(\Google_Service_Storage $service) | ||
{ | ||
$this->beConstructedWith($service, 'bucketName'); | ||
} | ||
|
||
public function it_is_adapter() | ||
{ | ||
$this->shouldHaveType('Gaufrette\Adapter'); | ||
} | ||
|
||
public function it_supports_metadata() | ||
{ | ||
$this->shouldHaveType('Gaufrette\Adapter\MetadataSupporter'); | ||
} | ||
|
||
public function it_is_list_keys_aware() | ||
{ | ||
$this->shouldHaveType('Gaufrette\Adapter\ListKeysAware'); | ||
} | ||
} |
Oops, something went wrong.