This repository has been archived by the owner on Jul 17, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 146
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
✨ Authentification without Json File (#53)
* ✨ Add possibility to authenticate directly without json file * 📝 Update Readme * Use early return instead of else. * Fix Bracket * Apply suggestions from code review (usage of array_get) Co-Authored-By: rommni <rombatie@hotmail.fr>
- Loading branch information
Showing
2 changed files
with
39 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -64,10 +64,8 @@ public function boot() | |
$factory = $this->app->make('filesystem'); | ||
/* @var FilesystemManager $factory */ | ||
$factory->extend('gcs', function ($app, $config) { | ||
$storageClient = new StorageClient([ | ||
'projectId' => $config['project_id'], | ||
'keyFilePath' => array_get($config, 'key_file'), | ||
]); | ||
$storageClient = $this->createClient($config); | ||
|
||
$bucket = $storageClient->bucket($config['bucket']); | ||
$pathPrefix = array_get($config, 'path_prefix'); | ||
$storageApiUri = array_get($config, 'storage_api_uri'); | ||
|
@@ -78,6 +76,28 @@ public function boot() | |
}); | ||
} | ||
|
||
/** | ||
* Create a new StorageClient | ||
* | ||
* @param mixed $config | ||
* @return \Google\Cloud\Storage\StorageClient | ||
*/ | ||
private function createClient($config) | ||
{ | ||
if (is_string(array_get($config, 'key_file'))) { | ||
return new StorageClient([ | ||
'projectId' => $config['project_id'], | ||
'keyFilePath' => array_get($config, 'key_file'), | ||
]); | ||
} | ||
|
||
return new StorageClient([ | ||
'projectId' => $config['project_id'], | ||
'keyFile' => array_merge([ | ||
"project_id" => $config['project_id'] | ||
], array_get($config, 'key_file', []) | ||
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong.
RazmikSaghoyan
|
||
]); | ||
} | ||
|
||
/** | ||
* Register bindings in the container. | ||
|
syntax error, please fix