ReactJS,上传文件时尝试将URL图像插入数据库

时间:2018-09-25 19:27:09

标签: reactjs firebase firebase-realtime-database

有什么方法可以从reactJS的firebase的上传中获取URL,然后将其插入带有URL标记的我的client对象中?

handleUploadSuccess = filename => {
  this.setState({ avatar: filename, progress: 100, isUploading: false });
  firebase
    .storage()
    .ref("images")
    .child(filename)
    .getDownloadURL()
    .then(url => this.setState({ avatarURL: url } ))
    .then(function(snapshot)
    {
      const url = snapshot.getDownloadURL();
      const clientRef = firebase.database().ref('clients');
      const clientsData = {
        companyName: this.companyName.value,
        ID: this.state.ID,
        URL: url


      }
    });

};

0 个答案:

没有答案