Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

192
Vistas
How to get an mhtml blob out of post request correctly

I am trying to achieve the following. I have a chrome extension which performs a page capture using chrome.pageCapture API. It returns a blob containing an MHTML file. I then create a new FormData object, attach my blob to it and pass it to the XMLHttpRequest function. Here's the full code that does it:

        chrome.tabs.query(queryOptions, (tabs) => {
            let tab = tabs[0];
            chrome.pageCapture.saveAsMHTML(
              {tabId:tab.id},
              function(mhtml) {
                let xhr = new XMLHttpRequest();
                let formData = new FormData();

                formData.append("mhtml", mhtml);

                xhr.open("POST", "http://localhost:8080", true);
                xhr.send(formData);
              }
            )
        });

I then try to save this MHTML file to disk using Node.js. In order to do that I created and started a local server on port 8080 and am listening for requests there. My POST request comes in fine, and I assume saving it would entail converting it back to a Buffer and using something like fs.writeFile('page.mhtml', buffer);

But I am not quite sure what's the correct way of extracting my blob from the request. Any tips would be very welcome.

Thank you!

about 4 years ago · Juan Pablo Isaza
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda