Last active
February 7, 2022 23:53
-
-
Save flagtick/93e4f373f4c7f71ed3eb032fc17668fb to your computer and use it in GitHub Desktop.
Laravel/Google Drive V3/GoogleDriveServiceProvider.php
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
<?php | |
namespace App\Providers; | |
use Illuminate\Support\ServiceProvider; | |
use League\Flysystem\Filesystem; | |
class GoogleDriveServiceProvider extends ServiceProvider | |
{ | |
/** | |
* Bootstrap the application services. | |
* | |
* @return void | |
*/ | |
public function boot() | |
{ | |
\Storage::extend('google', function($app, $config) { | |
$client = new \Google_Client(); | |
$client->setClientId($config['clientId']); | |
$client->setClientSecret($config['clientSecret']); | |
$client->refreshToken($config['accessToken']); | |
$service = new \Google_Service_Drive($client); | |
$adapter = new GoogleDriveAdapter($service, $config['folderId']); | |
return new Filesystem($adapter); | |
}); | |
} | |
/** | |
* Register the application services. | |
* | |
* @return void | |
*/ | |
public function register() {} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment