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

150
Visualizações
extra info being added to image from input file in formData fetch request

Uploading image to S3 from typescript react client side but for some reason appending that file to formData adds extra info to the file (which corrupts it and can't be opened after downloading from S3). After removing that extra info from a text editor, the image opens fine. Anyone know why this is happening? I'm using fetch API with FormData

const onFileChange = (e: ChangeEvent<HTMLInputElement>) => {

    const formData = new FormData();
    if (e.target.files) {
      formData.append("file", e.target.files[0]);

      fetch(url, {
        method: "PUT",
        body: formData,
        headers: {
          "Content-Type": e.target.files[0].type,
        },
      })
        .then((response) => {
          console.log(response);
        })
        .catch((err) => {
          console.log(err);
        });
    }
  };

<input
    type="file"
    accept="image/*"
    name="photo"
     onChange={(e) => onFileChange(e)}
  />

enter image description here

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