답변

0

그래, 고쳐 주었어. 가져올 필요가 있습니다

const gcs = require('@google-cloud/storage')(); 

exports.onDeleteTimelapse = functions.database.ref("/timelapses/{id}") 
    .onDelete(event => { 

     imagesRef.orderByChild("parentId") 
      .equalTo(event.params.id) 
      .on("value", function (snapshot) { 
       snapshot.forEach(function (childSnapshot) { 
        childSnapshot.ref.remove(); //this calls method bellow 
       }); 
      }); 
    }); 

exports.onDeleteImage = functions.database.ref("/images/{id}") 
    .onDelete(event => { 

     const filename = event.params.id; 
     gcs 
      .bucket(bucketName) // find it in Firebase>Storage>"gs://...." copy without gs 
      //or go to console.cloud.google.com/ buckets and copy name 
      .file("images/" + filename) //file location in my storage 
      .delete() 
      .then(() => { 
       console.log(`gs://${bucketName}/${filename} deleted.`); 
      }) 
      .catch(err => { 
       console.error('ERROR-DELETE:', err+ " filename: "+filename); 
      }); 

    });