Skip to content
This repository was archived by the owner on Jul 17, 2024. It is now read-only.
Open
Changes from all 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
27 changes: 15 additions & 12 deletions src/GoogleCloudStorageServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -84,21 +84,24 @@ public function boot()
*/
private function createClient($config)
{
$keyFile = array_get($config, 'key_file');
if (is_string($keyFile)) {
return new StorageClient([
'projectId' => $config['project_id'],
'keyFilePath' => $keyFile,
]);
$options = [];
if (isset($config['project_id'])) {
$options['projectId'] = $config['project_id'];
}

if (! is_array($keyFile)) {
$keyFile = [];
if (isset($config['key_file'])) {
$keyFile = array_get($config, 'key_file');
if (is_string($keyFile)) {
$options['keyFilePath'] = $keyFile;
} else {
if (! is_array($keyFile)) {
$keyFile = [];
}
$options['keyFile'] = array_merge(["project_id" => $config['project_id']], $keyFile);
}
}
return new StorageClient([
'projectId' => $config['project_id'],
'keyFile' => array_merge(["project_id" => $config['project_id']], $keyFile)
]);

return new StorageClient($options);
}

/**
Expand Down