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

289
Visualizações
Upload multiple files in angular 10 and .net core 5 using json object

I have an json object in a structure like this:

Class->Students this is a rough representation of my typescript class

export class Classroom
{
Id:number;
Name:string;
Students:Student[]=[];
}

export class Student
{
Name:string;
Age:number;
Sex:string;
Image:File;
}

my data is very simple:

var classroom=new Classroom();
var student1=new Student();
student1.Name="Dexter";student1.Sex="male";student1.Age=28;
student1.Image='some file which is uploaded using input type=file'
classroom.push(student1);
var student2=new Student();
student2.Name="Alex";student2.Sex="male";student2.Age=20;
student2.Image='some file which is uploaded using input type=file'
classroom.push(student2);

I want to send this data to my api. if there was no image it was pretty simple but now if I use FormData to append every file to a FormData and send it to api, then at the api side I cant know what image belongs to whom?

if I append my image files to a FormData I will just have bunch of images at the backend but i wont be able to decide every picture belongs to whom?

and if i try to just send data as a body of post request like this

//service.ts
this.http.post(this.apiUrl+'/ControllerPath',classroom,{responseType:"json"});

I get an error like this:

System.NotSupportedException: The collection type 'Microsoft.AspNetCore.Http.IHeaderDictionary' on 'Microsoft.AspNetCore.Http.IFormFile.Headers' is not supported.

is there an easy to understand way to send multiple files to api but within a class or with a way to know each picture belongs to who (in my case)?

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

0

One way to answer the question is to encode image files into a string using base64 and then send that along with other data to the server-side.

you can get additional details here: How can I convert an image into Base64 string using JavaScript?

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