spatie / laravel-google-cloud-storage

Google Cloud Storage filesystem driver for Laravel
https://spatie.be/open-source
MIT License
196 stars 51 forks source link

TypeError: League\Flysystem\GoogleCloudStorage\GoogleCloudStorageAdapter::__construct(): #11

Closed bouffekai closed 2 years ago

bouffekai commented 2 years ago

Hello,

I just installed the package for Laravel 9 with the following config :

'gcs' => [ 'driver' => 'gcs', 'key_file_path' => env('GOOGLE_CLOUD_KEY_FILE', null), // optional: /path/to/service-account.json 'key_file' => json_decode(file_get_contents('credentials.json'), true), // optional: Array of data that substitutes the .json file (see below) 'project_id' => env('GOOGLE_CLOUD_PROJECT_ID', 'your-project-id'), // optional: is included in key file 'bucket' => env('GOOGLE_CLOUD_STORAGE_BUCKET', 'dev-eu-prioritis-developement'), 'path_prefix' => env('GOOGLE_CLOUD_STORAGE_PATH_PREFIX', null), // optional: /default/path/to/apply/in/bucket 'storage_api_uri' => env('GOOGLE_CLOUD_STORAGE_API_URI', null), // see: Public URLs below 'visibility' => 'public', // optional: public|private 'metadata' => ['cacheControl'=> 'public,max-age=86400'], // optional: default metadata ],

then I cleared the cache with artisan.

When I instanciate the storage : $disk = Storage::disk('gcs'); I get this error : TypeError: League\Flysystem\GoogleCloudStorage\GoogleCloudStorageAdapter::__construct(): Argument #2 ($prefix) must be of type string, null given, called in /Users/jeremyaublanc/Prioritis/laravel-prismaccess/vendor/spatie/laravel-google-cloud-storage/src/GoogleCloudStorageServiceProvider.php on line 45

Could you help me with this ? It seems something goes wrong because construct try to get 'root' field in config file but it doesn't exist.

Thank you Jeremy

XristMisyris commented 2 years ago

Replace path prefix default value from null to an empty string ( "" ).

https://github.com/spatie/laravel-google-cloud-storage/pull/8/files

bouffekai commented 2 years ago

https://github.com/spatie/laravel-google-cloud-storage/pull/8/files

Thank you !