我制作了一个社交媒体应用,用户可以在其中上传图片。我想为应用程序中的用户添加删除选项。我希望用户从Firebase云存储中删除其照片。这是我的代码
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
但是每当我尝试删除任何图片时,它都会返回错误
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" }}