Skip to content
Open
Show file tree
Hide file tree
Changes from 11 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,5 @@ tests/adapters/*
bin/*
!bin/configure_test_env.sh
doc/.couscous
nbproject/*
tests/Gaufrette/Functional/adapters/*.php
3 changes: 2 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,8 @@
"phpunit/phpunit": "3.7.*",
"microsoft/windowsazure": "dev-master",
"mikey179/vfsStream": "~1.2.0",
"league/flysystem": "~1.0"
"league/flysystem": "~1.0",
"google/cloud": ">=0.20.1"
Copy link

@AntoineLelaisant AntoineLelaisant Mar 30, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This dep should be added in the suggest section, because there is no need to install this library if you don't need to use your GoogleCloud adapter.

We opened an RFC to find a better solution to this problematic #466

One more point: shouldn't we require 'google/cloud-storage' instead of the entire 'google/cloud' library (as it's recommended here https://github.com/GoogleCloudPlatform/google-cloud-php/tree/master/src/Storage in the README.md section) ?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agreed & fixed.

},
"suggest": {
"knplabs/knp-gaufrette-bundle": "to use with Symfony2",
Expand Down
52 changes: 52 additions & 0 deletions doc/adapters/google-cloud-client-storage.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
---
currentMenu: google-cloud-client-storage
---

# Google Cloud Client Storage

This adapter requires an instance of Google\Cloud\Storage\StorageClient that has proper access rights to the bucket you want to use.

For more details see:
http://googlecloudplatform.github.io/google-cloud-php/
https://console.cloud.google.com/

## Example

```php
<?php

use Gaufrette\Filesystem;
use Gaufrette\Adapter\GoogleCloudClientStorage;

$storage = new StorageClient(array(
'projectId' => 'your-project-id',
'keyFilePath' => 'path/to/your/project/key.json'
));

# you can optionally set the directory in the bucket and the acl permissions for all uploaded files...
# by default the uploaded files are read/write by the owner only
# the example below gives read access to the uploaded files to anyone in the world

$adapter = new GoogleCloudClientStorage($storage, 'bucket_name',
array(
'directory' => 'bucket_directory',
'acl' => array(
'allUsers' => \Google\Cloud\Storage\Acl::ROLE_READER
)
)
);

$key = 'myAmazingFile.txt';

# optional
$adapter->setMetadata($key,
array(
'FileDescription' => 'This is my file. There are many like it, but this one is mine.'
)
);

$filesystem = new Filesystem($adapter);

$filesystem->write($key, 'Uploaded at: '.date('Y-m-d @ H:i:s'), true);

```
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you have any idea what's the minimum set of security access (roles?) needed to use it? Would be awesome to provide something equivalent to this. But that's a detail, it could be postpone to another PR.

Loading