我想使用google驱动器作为文件系统的磁盘,为此我已经安装了"nao-pon/flysystem-google-drive": "~1.1",包&配置了如下所示的config/filesystem.php
'disks' => [
'google' => [
'driver' => 'google',
'clientId' => env('GOOGLE_DRIVE_CLIENT_ID'),
'clientSecret' => env('GOOGLE_DRIVE_CLIENT_SECRET'),
'refreshToken' => env('GOOGLE_DRIVE_REFRESH_TOKEN'),
'folderId' => env('GOOGLE_DRIVE_FOLDER_ID'),
]
],GoogleDriveServiceProvider
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 \Hypweb\Flysystem\GoogleDrive\GoogleDriveAdapter($service, $config['folderId']);
return new \League\Flysystem\Filesystem($adapter);
});
}我已将.env上的所有凭据设置如下
FILESYSTEM_CLOUD=google
GOOGLE_DRIVE_CLIENT_ID=xxx.apps.googleusercontent.com
GOOGLE_DRIVE_CLIENT_SECRET=xxx
GOOGLE_DRIVE_REFRESH_TOKEN=xxx
GOOGLE_DRIVE_FOLDER_ID=xxx现在,如果我试图从google磁盘Storage::disk('google')->exists('abc.jpg')获取任何文件,它会说
“驱动程序google不受支持。”,“异常”:"InvalidArgumentException",
发布于 2021-01-21 09:49:42
看起来一切都配置正确,但您也可以检查是否将google服务提供商注册到config/app.php中,如果没有,则将其添加到提供者数组中,如下所示
providers=[
...
App\Providers\GoogleDriveServiceProvider::class,
],https://stackoverflow.com/questions/65822211
复制相似问题