title: How to delete image from firebase cloud storage
body: <p>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</p>
  <pre><code>val photoRef: StorageReference = FirebaseStorage.getInstance().getReferenceFromUrl(contentDTOs[p1].imageUrl.toString())
  photoRef.delete().addOnSuccessListener { // File deleted successfully
      Toast.makeText(context, &quot;onSuccess: deleted file&quot;,Toast.LENGTH_SHORT).show()
  }.addOnFailureListener { // Uh-oh, an error occurred!
      Toast.makeText(context, &quot;onFailure: did not delete file&quot;,Toast.LENGTH_SHORT).show()
  }
  
  return@setOnLongClickListener true
  </code></pre>
  <p>But whenever I try to delete any pic it returns me error</p>
  <pre><code>E/StorageException: StorageException has occurred.
      Object does not exist at location.
       Code: -13010 HttpResult: 404
  E/StorageException: {  &quot;error&quot;: {    &quot;code&quot;: 404,    &quot;message&quot;: &quot;Not Found.  Could not delete object&quot;,    &quot;status&quot;: &quot;DELETE_OBJECT&quot;  }}
      java.io.IOException: {  &quot;error&quot;: {    &quot;code&quot;: 404,    &quot;message&quot;: &quot;Not Found.  Could not delete object&quot;,    &quot;status&quot;: &quot;DELETE_OBJECT&quot;  }}
   
  </code></pre>