• Jobs
  • About Us
  • professionals
    • Home
    • Jobs
    • Courses and challenges
  • business
    • Home
    • Post vacancy
    • Our process
    • Pricing
    • Assessments
    • Payroll
    • Blog
    • Sales
    • Salary Calculator

0

319
Views
Convert Blob to JSON Object on Express Backend

I have an extremely large JSON Object that I wish to send to my ExpressJS Server as a blob. I was able to create the blob on the frontend but I'm not sure how to convert the blob back to the original JSON Object on the backend.

Here is my large JSON Object and how I converted it on the frontend:

let largeObject = {
   ...... //Redacted
};
const largeObjectStringified = JSON.stringify(largeObject);
const largeObjectBytes = new TextEncoder().encode(largeObjectStringified);
const largeObjectBlob = new Blob([largeObjectBytes], {
    type: "application/json;charset=utf-8"
});
const blobUrl = URL.createObjectURL(largeObjectBlob);

//Request body to send to server via axios
let requestBody = new FormData();
let blob = await fetch(blobUrl).then(r => r.blob());
requestBody.append('file', new File([blob], 'file', { type: 'application/json' }));

axios.post(endPoint,requestBody);

Now on my express server I'm reading the incoming blob like this:

let busboy = new Busboy({
    headers: req.headers
});
let uploadPath = path.join(__dirname, '..');
uploadPath = path.join(uploadPath, 'uploads/');
let filePaths = [];
busboy.on('file', function (fieldname, file, filename, encoding, mimetype) {
    let filePath = path.join(uploadPath, filename);
    filePaths.push(filePath);
    let writeStream = fs.createWriteStream(filePath);
    file.pipe(writeStream);
});
busboy.on('finish', async function () {
    let blobFilePath = filePaths[0]; //How do I read back the JSON Object from the file path?
});

Thanks

almost 3 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 Our process Sales
Legal
Terms and conditions Privacy policy
© 2025 PeakU Inc. All Rights Reserved.

Andres GPT

Recommend me some offers
I have an error