Firebase Storage error in Firebase Cloud Function

Viewed 318

I use const bucket = admin.storage().bucket(); in the cloud function, and at the very top, I have:

const functions = require('firebase-functions')
const admin = require("firebase-admin");
admin.initializeApp();

When I try to deploy, it gives me an error:

i functions: Loaded environment variables from. Error: Missing bucket name. If you are unit testing, please provide a bucket name through functions.storage.bucket(bucketName), or set process.env.FIREBASE_CONFIG.`

This only started happening after I updated, I believe. Thank you for your help.

2 Answers

After some more testing, I realized that the issue was not with admin.storage().bucket(), it was with functions.storage.object().onFinalize(... which should be functions.storage.bucket('{bucketname}').object().onFinalize(... instead.

Related