Click here to Skip to main content
15,889,863 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have made a social media app where users can upload there pic. I want to add a delete option for the users in the app. I want the users to delete their pic from Firebase cloud storage. Here is my code

val photoRef: StorageReference = FirebaseStorage.getInstance().getReferenceFromUrl(contentDTOs[p1].imageUrl.toString())
photoRef.delete().addOnSuccessListener { // File deleted successfully
    Toast.makeText(context, "onSuccess: deleted file",Toast.LENGTH_SHORT).show()
}.addOnFailureListener { // Uh-oh, an error occurred!
    Toast.makeText(context, "onFailure: did not delete file",Toast.LENGTH_SHORT).show()
}

return@setOnLongClickListener true

But whenever I try to delete any pic it returns me error

E/StorageException: StorageException has occurred.
    Object does not exist at location.
     Code: -13010 HttpResult: 404
E/StorageException: {  "error": {    "code": 404,    "message": "Not Found.  Could not delete object",    "status": "DELETE_OBJECT"  }}
    java.io.IOException: {  "error": {    "code": 404,    "message": "Not Found.  Could not delete object",    "status": "DELETE_OBJECT"  }}


What I have tried:

I am trying to delete images from firebase cloud store.
Posted
Updated 23-Oct-20 4:12am

1 solution

Based on the documentation: ErrorCode  |  Firebase[^]

HTTP error code = 404 == UNREGISTERED

Quote:
App instance was unregistered from FCM. This usually means that the token used is no longer valid and a new one must be used. This error can be caused by missing registration tokens, or unregistered tokens.
Missing Registration: If the message's target is set to token, check that the request contains a registration token.
Not registered: An existing registration token may cease to be valid in a number of scenarios, including:
- If the client app unregisters with FCM.
- If the client app is automatically unregistered, which can happen if the user uninstalls the application. For example, on iOS, if the APNS Feedback Service reported the APNS token as invalid.
- If the registration token expires (for example, Google might decide to refresh registration tokens, or the APNS token has expired for iOS devices).
- If the client app is updated but the new version is not configured to receive messages. For all these cases, remove this registration token from the app server and stop using it to send messages.

Please try with proper registration tokens.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900