Firebase storage Delete

Hi all,

need help with deleting files (images) from Firebase storage.

In my app I create database of items stored in Firestore database and each item has couple of text and numeric information (name, dimensions, etc.) and URL adres of image of this item which is uploaded to Firebase storage. I have also list of these items in my app from where I can open detail of each item. In this detail I have button for deleting this item from database BUT I don’t know how to delete the image from Firebase storage. I can delete this item from database with “Data - delete record” so it no longer shows in the list, but this will only delete item record and not uploaded image becouse it contains only URL of this image.

Is there any function for deleting files from Firebase Storage? I use Data - Upload files for import, but I don’t know what to use for Deleting files.

Any advice?

Hello there,

I have been struggling with the same issue… Trying to find a solution how to delete a file from Firebase storage when I have the security rules to check if the request is authorised or not.
So in Firebase I have the following security rules:

allow read, write, delete: if request.auth != null;

Without this rule I could in fact use the download url of the file to send an HTTP ‘DELETE’ request to that url and that did ‘DELETE’ the file from the Storage, but this only works if delete rule is allowed to public (allow delete: if true). Howver the Firebase docs show that there should be a

var fileRef = Firebase.storage.refFromUrl(filedownloadURL);
fileRef.delete()

method available. I wonder if it is available in Appgyver as well?

I have some good news for you! I just published a flow function for getting the id token of an authenticated firebase user – that should solve this problem for you as you’ll be able to get the id token and thus do the authenticated HTTP Request to your Firebase backend :relaxed:

1 Like

I stumbled upon this just recently. Can you provide a quick overview of how to use this in conjunction with the HTTP request flow function in order to accomplish the task of deleting a file from firebase storage? My best efforts keep resulting in 400 errors.

Unfortunately I’m not familiar enough with Firebase to do that :sweat_smile:

Simply do a HTTP request with method “DELETE” and the URL should be the “downloadUrl” of the firebase storage file.

Like this:

Note that this will only work if the security rules are not set to rerquest.auth != null in firebase storage. This is not a good idea however, but I still have to figure out how to delete a file if security rules are on.