I'm trying to include service account key into my storage function to be able to get long lived signed url by following out of date example here
I have downloaded my key from IAM which is in JSON format. I have tried to save it right next to my function
-functions/storage/resizeProfileImg.js
-functions/storage/service-account-credentials.json
-functions/index.js
-functions/admin.js
where resizeProfileImg.js is my function and call it like this
const { Storage } = require('@google-cloud/storage');
const storage = new Storage({ projectId: projectId ,keyFilename: './service-account-credentials.json'})
but after deployment when the function is triggered then I get an error
Error: ENOENT: no such file or directory, open '/srv/service-account-credentials.json'
I have even tried to add it in constant like this
const serviceAccountCredentials = require('./accountKey/service-account-credentials.json')
const { Storage } = require('@google-cloud/storage');
const storage = new Storage({ projectId: projectId ,keyFilename: serviceAccountCredentials})
but then I get an error
TypeError: Path must be a string. Received { type: 'service_account',...
Any idea how to do this properly