How to delete files not found in a document in firebase


I’m using quill as text editor in an Angular project. It has an image/video handler that uploads files to firebase. If the user adds an image in the editor the image is uploaded to firebase storage. If the user deletes the image with the keyboard, then the image is deleted from the editor but it keeps stored in the storage. This results in many images uploaded and not being used in any firestore ddocument.

I was thinking about a firebase function in which if an image is not used in any document then it can be deleted at certain time. Not sure how to start.

Another way is to save the uploaded images to an array and then when the editor form is saved it matches the elements in the array vs what it finds in the html saved from the editor in a forestore document. I tried this one but the url is not found. In the below code imageArray is where I’m pushing uploaded urls and then this.noticia.quillContent is what is being stored in firestore document. This returns null, I believe match is not getting the url text within the string.

findImage() {
  this.imageArray.forEach(element => {
    const found = this.noticia.quillContent.match(element);

I’m not sure which way is better. There’s a keybinding for quill for the backspace key but it would also need to find what to delete.

Source: Angular Questions


Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Still Have Questions?

Our dedicated development team is here for you!

We can help you find answers to your question for as low as 5$.

Contact Us