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

183
Views
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
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!