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

118
Visualizações
Remove "filename" header from FormData

I'm trying to post a request using FormData(), I need to include the "content type" header so I'm using the blob to append entries to my form, but this automatically sets the filename to "blob"

const formData = new FormData();

        const obj1 = new Blob([json_data], {type: 'text/plain; encoding=utf-8'});
        formData.append("small_config", obj1);

        const obj2 = new Blob([client], {type: 'text/plain; encoding=utf-8'});
        formData.append("app_type", obj2);

        const obj3 = new Blob([version], {type: 'text/plain; encoding=utf-8'});
        formData.append("product_version", obj3);

        let thumb = await fetch(my_url, {
            method: 'POST',
            mode: 'cors',
            cache: 'no-cache',
            credentials: 'same-origin',
            redirect: 'follow',
            referrerPolicy: 'no-referrer',
            body: formData
        });

Is there a way to both set the content type and not include filename?

about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

There is no way to have FormData not send a filename with an appended blob. You can send an empty string however.

Use the 3rd parameter to FormData.append

formData.append("small_config", obj1, 'My Filename');

So for your case, try an empty string.

formData.append("small_config", obj1, '');

From Mozilla docs:

filename Optional
The filename reported to the server (a USVString), when a Blob or File is passed as the second parameter. The default filename for Blob objects is "blob". The default filename for File objects is the file's filename.

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