简体   繁体   中英

How can I Update Blogpost Featured Image in Firebase Storage?

I'm trying to replace an image with an already existing one in my blogpost using firebase storage with ReactJS. However, it uploaded but not replacing the old one rather creates a duplicates without the image. Here's the code, anyone who can help please, thanks.

handleUploadSuccess = filename => {
  this.setState({
    editImage: filename,
      progress: 100
    })
    firebase.storage().ref('featureds').child(filename).getDownloadURL()
      .then(url => this.setState({
        editImageURL: url
      }))
    }

I have figured out the solution. The code is correct, the issue was from passing firebase parameter, implemented this way

this.props.firebase.blog(blog.uid).set({...

Instead of this

this.props.firebase.blog(this.props.match.params.id).set({...

Thanks.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM