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

201
Visualizações
Angular FormData cannot append my data like in React

I'm recording an audio file and sending it to a server using multipart/formdata. In React, my FormData is good, but not in Angular.

My React version works great, here it is :

let data = new FormData();             
data.append("file", {
uri: uri,
name: "file.m4a",
type: "audio/m4a",
});

If I console.log this data, I get for example :

{"_parts":[["file",{"uri":"file:///data/user/0/com.app/cache/Audio/recording.m4a","name":"file.m4a","type":"audio/m4a"}]]}

Now, I need this for Angular version, but FormData are not defined the same, and I don't know how to correct this.

If I do the same for Angular, I have an error :

Argument of type '{ uri: string; name: string; type: string; }' is not assignable to parameter of type 'string | Blob'.

And if I console.log the data, I get nothing.

What is the correct version for appending my data for Angular, with these parameters ?

In Angular, the definition of FormData is :

declare var FormData: {
    prototype: FormData;
    new(form?: HTMLFormElement): FormData;
};
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