Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

371
Views
Reaccionar nativo, escribir una cadena xml en un archivo .xml y enviarlo al servidor

Estoy tratando de enviar una cadena xml como un archivo .xml al servidor, ya que pude crear un archivo .xml y escribí datos en él con la ayuda de react-native-fs pero no puedo enviarlo a api. Creo que no está recogiendo el camino. ¿Alguien puede decirme cómo hacerlo correctamente?

Aquí está mi código

 const getToken = async () => { updateState({isLoading: false}); const xml = await onJsonToXmal(); //create path for that xml file const path = RNFS.DocumentDirectoryPath + '/test.xml'; // write xml into that file RNFS.writeFile(path, xml, 'utf8') .then((success: any) => { // console.log(success, 'success'); }) .catch((err: any) => { // console.log(err.message); }); const checksum = md5(xml); const formData = new FormData(); formData.append('file', { uri: path, type: 'xml', name: 'demo.xml', }); // formData.append('checksum', checksum); axios({ method: 'post', url: 'some url', headers: { 'Content-Type': 'multipart/form-data', Authorization: 'Bearer some token', }, data: { file: formData, checksum, }, }) .then(res => { console.log(res.data); updateState({isLoading: false}); }) .catch(error => { console.log(error); Alert.alert(`${error}`); updateState({isLoading: false}); }); }; const onJsonToXmal = () => { const data = dummyData; //dataForXml const res = toXML(data); return res; };

gracias

about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!