如何使用 Axios React Native 上传图片?

How To Upload Image Using Axios React Native?

我用的是react-native-image-picker,成功从相机拍照后我想上传到服务器。这是我用于上传图片的 Axios PUT 代码:

updateBodyTemperature = async () => {
    try {
      let fistNumber = this.state.textOne.toString()
      let secondNumber = this.state.textTwo.toString()
      let thirdNumber = this.state.textThree.toString()
      let resultOutputNumber = fistNumber + secondNumber + ',' + thirdNumber
      let fd = new FormData()
      fd.append('image', 'file:///' + this.state.markResult)
      let response = await API.put(
        'vendor/tenant-users/body-temperature-data',
        {
          'image': fd,
          'temperature': resultOutputNumber
        },
        {
          headers: {
            'Authorization': 'Bearer ' + await AsyncStorage.getItem(Config.VENDOR_ACCESS_TOKEN),
            'Content-Type': 'multipart/form-data'
          }
        })
      alert('Berhasil')
      if (response.data.success){
        this.setState({isFull: true})
      }


    } catch (error) {
      console.log(error.response)
      alert('Gagal')

    }

  }

有link或出处请帮忙,谢谢

为了在 React Native 中轻松上传图片,您可以使用

https://www.npmjs.com/package/rn-fetch-blob