Tag Archives: React native android

React native android: How to Upload Formdata

  let resizedImage = file // file
  let formData = new FormData();
  let name = `xxxx.jpeg`;
  let file = { uri: "file:///" + resizedImage.path.split("file:/").join(""), type: 'image/png', name: escape(resizedImage.name), fileType: 'image/\*' };   //The key here (uri and type and name) cannot be changed,
  formData.append("file", file); //the files here are the key needed by the backend
  formData.append("token", token); //the files here are the key needed by the backend
  formData.append("key", Math.random()+'__'+name); //the files here are the keys needed by the backend