CodeExplorer bucket example
public function create(array
$config) { $options =
$this->
resolveStorageConfig($config);
$storageClient =
new StorageClient([ 'projectId' =>
$options['projectId'
],
'keyFilePath' =>
$options['keyFilePath'
],
]);
$bucket =
$storageClient->
bucket($options['bucket'
]);
return new GoogleStorageAdapter($storageClient,
$bucket,
$options['root'
]);
} /**
* @return string
*/
public function getType() { return 'gcp';
} public function create(array
$config): FilesystemAdapter
{ $options =
$this->
resolveStorageConfig($config);
$storageConfig =
['projectId' =>
$options['projectId'
]];
if (isset($config['keyFile'
])) { $storageConfig['keyFile'
] =
$options['keyFile'
];
} else { $storageConfig['keyFilePath'
] =
$options['keyFilePath'
];
} $bucket =
(new StorageClient($storageConfig))->
bucket($options['bucket'
]);
return new GoogleCloudStorageAdapter($bucket,
$options['root'
]);
} public function getType(): string
{ return 'google-storage';
} private function resolveStorageConfig(array
$definition): array
{ $newServers[] =
$matches['host'
];
} $option =
isset($matches['options'
]) ? '?'.
$matches['options'
] : '';
$connectionString =
$protocol.'://'.
implode(',',
$newServers).
$option;
$clusterOptions =
new ClusterOptions();
$clusterOptions->
credentials($username,
$password);
$client =
new Cluster($connectionString,
$clusterOptions);
$bucket =
$client->
bucket($matches['bucketName'
]);
$collection =
$bucket->
defaultCollection();
if (!
empty($matches['scopeName'
])) { $scope =
$bucket->
scope($matches['scopeName'
]);
$collection =
$scope->
collection($matches['collectionName'
]);
} return $collection;
} finally { restore_error_handler();
} }