Skip to content

Commit

Permalink
Merge branch 'master' of github.com:Superbalist/flysystem-google-storage
Browse files Browse the repository at this point in the history
  • Loading branch information
matthewgoslett committed May 19, 2016
2 parents 4972d7f + 52e2baf commit 0c0530c
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 6 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,5 @@ composer.lock
vendor
bin
coverage
coverage.xml
coverage.xml
dev
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ composer require superbalist/flysystem-google-storage
## Usage

```php
use Superbalist\Flysystem\GoogleStorage\GoogleStorageAdapter
use Superbalist\Flysystem\GoogleStorage\GoogleStorageAdapter;
use League\Flysystem\Filesystem;

$credentials = new \Google_Auth_AssertionCredentials(
Expand All @@ -32,7 +32,7 @@ $client->setDeveloperKey('[[your developer key]]');

$service = new \Google_Service_Storage($client);

$adapter = new GoogleStorageAdapter($service, '[[your bucket name]]')
$adapter = new GoogleStorageAdapter($service, '[[your bucket name]]');

$filesystem = new Filesystem($adapter);
```
Expand Down
12 changes: 9 additions & 3 deletions src/GoogleStorageAdapter.php
Original file line number Diff line number Diff line change
Expand Up @@ -135,10 +135,16 @@ protected function upload($path, $contents, Config $config)
*/
protected function normaliseObject(\Google_Service_Storage_StorageObject $object)
{
$name = $object->getName();
$isDir = substr($name, -1) === '/';
if ($isDir) {
$name = rtrim($name, '/');
}

return [
'type' => 'file',
'dirname' => Util::dirname($object->getName()),
'path' => $object->getName(),
'type' => $isDir ? 'dir' : 'file',
'dirname' => Util::dirname($name),
'path' => $name,
'timestamp' => strtotime($object->getUpdated()),
'mimetype' => $object->getContentType(),
'size' => $object->getSize(),
Expand Down

0 comments on commit 0c0530c

Please sign in to comment.