1

当我尝试从“react-native-fs”uploadFiles 上传文件时。文件未上传。但是文件存在于 RNFS.DocumentDirectoryPath

在此处输入图像描述

var files = [{name: "CCM_Errorlog",filename: "CCM_Errorlog_" + now + "_" + driverIdNew + ".txt",filepath: RNFS.DocumentDirectoryPath + "/CCM_Errorlog_Copy.txt"}];

RNFS.uploadFiles({
        toUrl: uploadUrl,
        binaryStreamOnly:true,
        files: files,
        method: "POST",
        headers: {
          Accept: "application/json",
        },
        begin: uploadBegin,
        progress: uploadProgress
      })
        .promise.then(response => {
          console.log("Response_up:"+ JSON.stringify(response));
          if (response.statusCode == 200) {
            console.log("FILES UPLOADED!:" + JSON.stringify(response)); // response.statusCode, response.headers, response.body
            alert(JSON.stringify(response));
          } else {
            alert(JSON.stringify(response));
            console.log(response);
            console.log(RNFS.DocumentDirectoryPath);
          }
        })
        .catch(err => {
          if (err.description === "cancelled") {
            // cancelled by user
            console.log("Uploading Canceleed by User");
          }
          alert("uploadFile Error" + err);
        });
4

0 回答 0