Skip to content

Commit

Permalink
Backup on google drive and google drive as file system complete.
Browse files Browse the repository at this point in the history
  • Loading branch information
subhadipghorui committed Jan 20, 2021
1 parent bc6f6cb commit 14691a2
Show file tree
Hide file tree
Showing 6 changed files with 593 additions and 7 deletions.
42 changes: 42 additions & 0 deletions app/Providers/GoogleDriveServiceProvider.php
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);
});

}
}
2 changes: 2 additions & 0 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,14 @@
"brian2694/laravel-toastr": "^5.54",
"fideloper/proxy": "^4.2",
"fruitcake/laravel-cors": "^1.0",
"google/apiclient": "^2.7",
"guzzlehttp/guzzle": "^6.3",
"intervention/image": "^2.5",
"laravel/framework": "^7.0",
"laravel/socialite": "^5.1",
"laravel/tinker": "^2.0",
"laravel/ui": "^2.1",
"nao-pon/flysystem-google-drive": "~1.1",
"spatie/laravel-backup": "^6.14"
},
"require-dev": {
Expand Down
Loading

0 comments on commit 14691a2

Please sign in to comment.