thisbejim / Pyrebase

A simple python wrapper for the Firebase API.
2.05k stars 525 forks source link

How to delete file from Firebase Storage #170

Open yashleo21 opened 7 years ago

yashleo21 commented 7 years ago

Is this feature supported by Pyrebase to delete a file from Firebase Storage? I cannot find any documentation related to it. Thanks in advance!

nerfsmurf commented 7 years ago

I also would like to know if one can delete a file from Firebase Storage using Pyrebase

yukoba commented 7 years ago
storage = firebase.storage()
storage.delete("test.txt")
nerfsmurf commented 7 years ago

I don't seem to be able, using storage.delete(item), or storage.delete(str(item)) to be able to get around this error:

.../pyrebase/pyrebase.py line 410 in delete self.bucket.delete_blob(name) AtttributeError: 'Storage' object has no attribute 'bucket'

help?

janissary1 commented 6 years ago

Nothing I have tried has worked, looking through the code there does seem to be a delete function in the Storage class however it does not work??

janissary1 commented 6 years ago

Hey guys I found the solution to the problem. You need service account credentials in order to be authorized to delete from storage. This link under "Add firebase to your app" will walk you through how to add service account credentials to your config which will allow you to delete from storage.

Once you download the .json file containing the key, add a line to your config dictionary "serviceAccount":PATH_TO_JSON (for python)

bloughran618 commented 5 years ago

I am getting the same issue as earlier posters, AttributeError: 'Storage' object has not attribute 'bucket'. I have my service account role set to Storage Admin. Is there another role I need to enable to be able to delete items?

I have also confirmed that I can add files to Storage using storage.child("test.txt").put("test.txt"), so I am surprised that I cannot delete as well

19981999ab commented 5 years ago

@bloghran618 Did you solve the issue?

bloughran618 commented 5 years ago

Not really, but I found a workaround to using Pyrebase

19981999ab commented 5 years ago

@bloghran618 How did you do it?

bloughran618 commented 5 years ago

Well my application was written in Swift, just with a python backend, so I just had Swift delete the entry to firebase rather than use pyrebase

piedrucci commented 4 years ago

@janissary1 thanks so much!!! its work for me.... ;)