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

902
Views
How to send zip Files to a Node Server via HTTP POST? (server always only receives "{}")

For my Bachelor's Thesis, I am writing a program to visualize personal data requested via GDPR Art.20. Since this kind of data is normally zipped, I need to be able to send zipped files to my node.js server. This is what I have done so far.

            async function test (element){
            let file = element.files[0];
            await base64(file);
            async function base64(file){
                let reader = new FileReader();
                reader.readAsDataURL(file);
                reader.onload = await async function () {
                    console.log(reader.result);
                    fetch('/api', {
                        method: 'POST',
                        body: reader.result,
                    })
                        .then(response => response.json())
                        .then(result => {
                            console.log('Success:', result);
                        })
                        .catch(error => {
                            console.error('Error:', error);
                        });
                };
                reader.onerror = function (error) {
                    console.log('Error: ', error);
                };
            };
        }

At this point I am only trying to console.log() my request.body, but nevertheless here is my server code:

const { response } = require("express");
const express = require("express");
const { request } = require("http");
const JSZip = require("jszip");
const app = express();
app.listen(1234, () => console.log("Listening at 1234"));
app.use(express.static("public"));
app.use(express.json({limit: "10000mb"}))

app.post("/api", async (request, response) => {
    console.log(request.body);
    response.json({status: "success33"});
});

When I log reqeust.body it is empty "{}". Does someone knows the question for this? I read a lot of threads, but none would really fit my problem.

Thanks in advance!

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

i was facing the same problem, and when i added this middleware:

import * as fileUpload from 'express-fileupload';
app.use(fileUpload({createParentPath:true})) 

the problem has gone, and i was able to get any file from req.files

about 4 years ago · Juan Pablo Isaza Report
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!