拍摄一张照片后相机冻结

时间:2019-04-04 19:15:55

标签: android react-native react-native-camera

我有几个输入字段,并在它们下方渲染了摄影机视图。当用户在字段中提交数据时,将拍摄一张照片并将其保存到服务器,但是相机视图会停留在最后拍摄的照片上。

预期的行为: 摄像机视图显示提交后摄像机前面的内容

实际行为: 相机视图冻结最后拍摄的照片

按下提交时:

this.camera
                .capture({ metadata: options })
                .then(data => {
                  PicturePath = data.path;
                  picName = dataStored.licNum;
                  storePicture();
                })
                .catch(err => console.error(err));

// store picture function
function storePicture() {
  console.warn(PicturePath);
  if (PicturePath) {
    // Create the form data object
    var data = new FormData();
    data.append("guestPicture", {
      uri: PicturePath,
      name: picName,
      type: "image/jpg"
    });

    // Create the config object for the POST
    // You typically have an OAuth2 token that you use for authentication
    const config = {
      method: "POST",
      body: data
    };

    fetch(serverIP, config)
      .then(responseData => {
        // Log the response form the server
        // Here we get what we sent to Postman back
        console.warn(responseData);
      })
      .catch(err => {
        console.log(err);
      });
  }
}

0 个答案:

没有答案