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

143
Vistas
Can't upload large files

I am using react on frontend and express on backend.

Here is my code that I use to upload files:

    const formData = new FormData();
    formData.append('file', blob);
    formData.append('title', videoName);

    const request = new XMLHttpRequest();
    request.open('POST', `${process.env.URL}/api/video`); 
    request.withCredentials = true;
    request.setRequestHeader('lang', router.locale as string)
    request.upload.onprogress = e => {
        setUploadProgress(Math.floor((e.loaded / e.total) * 100));
    };
    request.onload = () => {
        const resp = JSON.parse(request.response);
        setRequestErr({
            mess: resp.message, 
            code: resp.statusCode
        })
        resp.statusCode === 401 && logoutUser()
        setIsVideoBeingSent(false);
        setModalType('info')
        
        if(resp.status === 200){
            setModalInfoType('success')
        } else{
            setModalInfoType('fail')
        }
    };

    request.send(formData);

It works perfectly locally, on both smaller and larger files (up to 150mb).

The problem occurs when I try to upload the file to a server hosted on amazon. The 150mb file stops at about 25 percent and does not move further.

I am using express-fileupload with settings:

const fileUpload = require('express-fileupload');

let Options = {
    limits: { fileSize: 200 * 1024 * 1024 },
    useTempFiles: true,
    abortOnLimit: true,
    tempFileDir: './content/tmp/',
    uploadTimeout: 0,
    debug: true,
}

router.post("/", TokenVerify, fileUpload(Options), UploadVideo);

Console in server shows nothing, no errors or other messages. Console in the browser returns only:

POST /api/video net::ERR_CONNECTION_ABORTED

What could be the cause of this?

about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

If you are using a virtual machine or a service that uses one on your amazon server, then chances are that you are using either Apache or Nginx to proxy your traffic on port 80 to your app. Meaning your express server configurations as far as upload file limits are concerned don't matter at all, but the one's on the http server you are using, so if it's Nginx: set the client_max_body_size directive to your desired limit, eg, client_max_body_size 100; This can be done as explained on this answer

And as for apache, this ought to help you: apache file upload limit settings

However if you don't have ssh access to your production environment, then their should be a server configuration file you can use to edit the limits. Or some gui settings you can edit.

The most important point here is that set your upload limit both on your express server and on the http server routing your clients' requests.

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