Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

141
Visualizações
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 Respostas
Responde à pergunta

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 Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda