I\'m trying to create a script in Cloud Functions for Firebase that will react to a db event and remove an image that has its path in one of the params (\"fullPath\").
t
Make sure your bucket name doesn't include gs://
Eg. instead of gs://my-project-id.appspot.com
use my-project-id.appspot.com
let bucket = gcs.bucket('my-project-id.appspot.com')
This may happen to you (as it did to me) if you copy your bucket name from, for instance, Android code, where you can use full URL to connect with storage, ie. storage.getReferenceFromUrl('gs://my-proj...
.
Also, it seems the projectId
variable you use to initialise gcs
doesn't need the appspot.com
suffix (but it shouldn't break if you have it included). Ie. projectId:'my-project-id'
should be suffice.
Lastly, the GCS node package docs states you need to generate separate JSON to pass as keyFilename
to test things locally. Good news is - you can use the Firebase Admin SDK key, as described in the Get Started Server/Admin docs instead.