如何从firebase云存储中删除图像

如何从firebase云存储中删除图像,firebase,kotlin,firebase-storage,Firebase,Kotlin,Firebase Storage,我制作了一个社交媒体应用程序,用户可以上传照片。我想为应用程序中的用户添加删除选项。我希望用户从Firebase云存储中删除他们的pic。这是我的密码 val photoRef: StorageReference = FirebaseStorage.getInstance().getReferenceFromUrl(contentDTOs[p1].imageUrl.toString()) photoRef.delete().addOnSuccessListener { // File delet

我制作了一个社交媒体应用程序,用户可以上传照片。我想为应用程序中的用户添加删除选项。我希望用户从Firebase云存储中删除他们的pic。这是我的密码

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"  }}
 

它看起来像
contentDTOs[p1]。imageUrl.toString()
没有引用云存储桶中的文件。它会将用户在ImageView中上载的图片返回给我如果打印检索到的值会怎么样?1.
contentDTOs[p1].imageUrl.toString()
。然后手动检查对象是否存在于您的Bucket中。您可以使用该工具,尝试使用以下命令:
gsutil ls gs://yourback/YoutFileName
。是的,通过使用contentDTOs[p1],我的图像存在于存储器中。imageUrl我在图像视图中检索图像