I am using laravel-google-cloud-storage package from github in my Laravel project to upload files to google cloud storage. I've a JSON file with credentials, project id and bucket list in my .env
file.
.env File
GOOGLE_CLOUD_PROJECT_ID='myproject-123456'
GOOGLE_CLOUD_KEY_FILE=/var/www/project/credintials.json
GOOGLE_CLOUD_STORAGE_BUCKET=minisite_event
.json credentials
{
"type": "service_account",
"project_id": "myproject-123456",
"private_key_id": "MY_PROJECT_KEY_ID",
"private_key": "-----BEGIN PRIVATE KEY-----\nTHEWHOLEKEYHEREWITHVERYVERYLONGTEXTLIKEANYOTHERPRIVATEKEYFILE=\n-----END PRIVATE KEY-----\n",
"client_email": "TEST@PROJECT_ID.iam.gserviceaccount.com",
"client_id": "99112211221122112211",
"auth_uri": "https://accounts.google.com/o/oauth2/auth",
"token_uri": "https://accounts.google.com/o/oauth2/token",
"auth_provider_x509_cert_url": "https://www.googleapis.com/oauth2/v1/certs",
"client_x509_cert_url": "https://www.googleapis.com/robot/v1/metadata/x509/ATESTSTRING.iam.gserviceaccount.com"
}
Filesystem Config
'gcs' => [
'driver' => 'gcs',
'project_id' => env('GOOGLE_CLOUD_PROJECT_ID', 'your-project-id'),
'key_file' => env('GOOGLE_CLOUD_KEY_FILE', null), // optional: /path/to/service-account.json
'bucket' => env('GOOGLE_CLOUD_STORAGE_BUCKET', 'your-bucket'),
'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
]
In my Laravel, I am trying to put the file in filesystem
$disk = Storage::disk('gcs');
$path = $disk->putFile('event_'.$id, $request->file('qqfile'));
Then I get this error:
NotFoundException
{
"error": {
"errors": [
{
"domain": "global",
"reason": "notFound",
"message": "Not Found"
}
],
"code": 404,
"message": "Not Found"
}
}
I am not sure what I am doing wrong. Also the package is not well documented and this is the best package I could find that already implemented Filesystem.