-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
nao-pon/flysystem-google-drive replacement
- Loading branch information
Showing
8 changed files
with
906 additions
and
11 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
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,49 @@ | ||
<?php | ||
|
||
namespace App\Providers; | ||
|
||
use Illuminate\Filesystem\FilesystemAdapter; | ||
use Illuminate\Support\ServiceProvider; | ||
use Illuminate\Support\Facades\Storage; | ||
use Masbug\Flysystem\GoogleDriveAdapter; | ||
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['refreshToken']); | ||
$service = new \Google\Service\Drive($client); | ||
|
||
$options = [ | ||
'useDisplayPaths' => false, // as nao-pon/flysystem-google-drive replacement | ||
]; | ||
if(isset($config['teamDriveId'])) { | ||
$options['teamDriveId'] = $config['teamDriveId']; | ||
} | ||
|
||
$adapter = new GoogleDriveAdapter($service, $config['folderId'] ?? null, $options); | ||
$driver = new Filesystem($adapter); | ||
return new FilesystemAdapter($driver, $adapter); | ||
}); | ||
} | ||
|
||
/** | ||
* Register the application services. | ||
* | ||
* @return void | ||
*/ | ||
public function register() | ||
{ | ||
// | ||
} | ||
} |
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 |
---|---|---|
|
@@ -2,4 +2,5 @@ | |
|
||
return [ | ||
App\Providers\AppServiceProvider::class, | ||
App\Providers\GoogleDriveServiceProvider::class, | ||
]; |
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.