-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Backup on google drive and google drive as file system complete.
- Loading branch information
1 parent
bc6f6cb
commit 14691a2
Showing
6 changed files
with
593 additions
and
7 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
<?php | ||
|
||
namespace App\Providers; | ||
|
||
use Google_Client; | ||
use Google_Service_Drive; | ||
use Hypweb\Flysystem\GoogleDrive\GoogleDriveAdapter; | ||
use Illuminate\Support\Facades\Storage; | ||
use Illuminate\Support\ServiceProvider; | ||
use League\Flysystem\Filesystem; | ||
|
||
class GoogleDriveServiceProvider extends ServiceProvider | ||
{ | ||
/** | ||
* Register services. | ||
* | ||
* @return void | ||
*/ | ||
public function register() | ||
{ | ||
// | ||
} | ||
|
||
/** | ||
* Bootstrap 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['refreshToken']); | ||
$service = new Google_Service_Drive($client); | ||
$adapter = new GoogleDriveAdapter($service, $config['folderId']); | ||
return new Filesystem($adapter); | ||
}); | ||
|
||
} | ||
} |
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
Oops, something went wrong.