Skip to content

Instantly share code, notes, and snippets.

@kublermdk
Created January 28, 2022 09:45
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kublermdk/8c2afd7e3ad88cfacdf80e435b44c3a8 to your computer and use it in GitHub Desktop.
Save kublermdk/8c2afd7e3ad88cfacdf80e435b44c3a8 to your computer and use it in GitHub Desktop.
Update creocoder\flysystem\GoogleCloudFilesystem to support the GoogleStorageAdapter which allows VISIBILITY_NOT_SET
<?php
/**
* @link https://github.com/creocoder/yii2-flysystem
* @copyright Copyright (c) 2015 Alexander Kochetov
* @license http://opensource.org/licenses/BSD-3-Clause
*
* Updated by Michael Kubler @kublermdk to support VISIBILITY_NOT_SET by using the different Google Storage Adapter
*/
namespace app\adaptors;
use Google\Cloud\Storage\StorageClient;
use \app\adaptors\GoogleStorageAdapter as GoogleStorageAdapter; // Point this to where-ever you place these
/**
* GoogleCloudFilesystem
* @package app\adaptors\GoogleCloudFilesystem
*
* To enable the use of the \Superbalist\Flysystem\GoogleStorage\GoogleStorageAdapter
*/
class GoogleCloudFilesystem extends \creocoder\flysystem\GoogleCloudFilesystem
{
/**
* @return GoogleStorageAdapter
*/
protected function prepareAdapter()
{
$config = [
'projectId' => $this->projectId,
'keyFilePath' => \Yii::getAlias($this->keyFilePath),
];
$client = new StorageClient($config);
$bucket = $client->bucket($this->bucket);
return new GoogleStorageAdapter($client, $bucket);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment