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

149
Views
Análisis de resultados de varias partes

Recibo un archivo json y una imagen desde el backend con datos de formularios/partes múltiples y tengo que analizarlo en el frontend.

 --47f5d03f-8473-428e-a4e7-11e2a0710dc2 �PNG gAMA���\@�! :����OZ�h���c�}�Յ��+.���* (etc with this data) --47f5d03f-8473-428e-a4e7-11e2a0710dc2 {"CustomerId":"123","Title":"This is title","Name":"This is name"} --47f5d03f-8473-428e-a4e7-11e2a0710dc2--

Json se analiza perfectamente, pero tengo un problema con la creación de imágenes. Pero Blob siempre me da un error cuando trato de usarlo para crear un elemento de imagen. Así es como traté de hacer esto.

 API.post(`api/endpoint`, data).then((resp) => { const boundIndex = resp.headers['content-type'].indexOf('boundary="') + 'boundary='.length; const contentType = resp.headers['content-type'] const bound = contentType.slice(boundIndex,contentType.length); const boundary = '--' + bound.slice(1, bound.length - 1); const splitedResponseData = resp.data.split(boundary); const jsonResponse = JSON.parse(splitedResponseData[2]); const blob = new Blob([splitedResponseData[1]], { type: 'image/png' }); const blob1 = new Blob([stringToUint(splitedResponseData[1])], { type: 'image/png' });

Blob1 está usando la función stringToUint() para convertir una cadena a Uint8Array.

 function stringToUint(stringData) { const string1 = btoa(unescape(encodeURIComponent(stringData))), charList = string1.split(''), uintArray = []; for (let i = 0; i < charList.length; i++) { uintArray.push(charList[i].charCodeAt(0)); } return new Uint8Array(uintArray); }

¿Estoy haciendo algo mal o hay otra forma de tomar una foto en función de los datos que obtengo?

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!