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

132
Visualizações
Send object with files to backend

So i have this problem that i have an object like:

{
   name: "",
   layers: [{
      name: "",
      traits: [{
         name: "",
         file: File
      }]
   }]
}

The problem is i cannot just JSON.stringify(data) and do an formData.append() and send it to the backend because the File cannot get searilized.

I also saw answer to send an array of images like:

formData.append("image", file1)
formData.append("image", file2)
...

But on the backend i will have the problem to put the image back to the right layer and to the right trait index.

Has anybody an idea whats the best way to achieve this goal?

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

0

Give each file a unique name (the third argument to append() lets you specify it). Create your data structure using those names instead of files. Serialise the data structure to JSON. Pass the JSON as a parameter in the FormData object.

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