title: How can we update the existing image in firebase cloud storage?
body: <p>I used <code>react-native-firebase</code> lib in my RN App</p>
  
  <p>and I use Firebase Storage to save image in the cloud so it's work very well but </p>
  
  <p>In profile screen and I have an <strong>Edit function</strong> that replaces the old image with a new one but it's just adding a new image to Firebase Cloud Storage not replaced it</p>
  
  <p>so there any way for just replacing old with new?</p>
  
  <p>because I don't want to increase my storage when users change his image profile </p>
  
  <p><a href="https://i.stack.imgur.com/lwogF.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/lwogF.png" alt="S"></a></p>
  
  <p>here is my function that's save new image profile</p>
  
  <pre><code> EditImg = async () =&gt; {
      const {uid, avatar} = this.state;
      let providerRef = database().ref(`Providers/users/${uid}`);
      const path = 'Avatar_' + new Date().getTime() + '.jpg';
      const ref = storage().ref(`providers/${uid}/providerGalary/${path}`);
      await ref.putFile(avatar).then(() =&gt; {
        ref.getDownloadURL().then(
          img =&gt; {
            console.log('img', img);
            providerRef
              .update({
                avatar: img,
              })
              .then(() =&gt; console.log('saved to Db Successfully'));
          },
          error =&gt; console.log(error),
        );
  
      });
    };
  </code></pre>