我正在 Symforny 5 中开发一个项目,我想使用 Google Cloud Storage,安装 phpleague / flysystem-bundle 并支持 superbalist / flysystem-google-storage,如文档中所述,在 Google Console 和存储桶中生成 credentials.json ,但我收到以下错误:
{
"error": {
"code": 401,
"message": "Invalid Credentials",
"errors": [
{
"message": "Invalid Credentials",
"domain": "global",
"reason": "authError",
"locationType": "header",
"location": "Authorization"
}
]
}
}
\vendor\google\cloud-core\src\RequestWrapper.php (line 362)
配置:
flysystem:
storages:
default.storage:
adapter: 'local'
options:
directory: '%kernel.project_dir%/var/storage/default'
gcs.storage:
adapter: 'gcloud'
options:
client: 'gcloud_client_service' # The service ID of the Google\Cloud\Storage\StorageClient instance
bucket: 'test-storage'
#prefix: 'optional/path/prefix'
api_url: 'https://storage.googleapis.com'
在 service.yml
gcloud_client_service:
class: Google\Cloud\Storage\StorageClient
arguments:
- projectId: 'storage-project'
- keyFilePath: '../credentials.json'