1

I'm trying to upload one Excel file at a time, with two other fields indicating how the file is going to be managed in the background. I've found some methods on which the .NET Core Web API doesn't receive and object itself, it recovers the file via

Request.Form.Files[0]

but I understand that with this method, I will not be able to send extra data.

I've got this so far in my TS file

      addPost(data: any){
    this.outVO = {
      tipoDeCargue: this.tipoDeCargueSelected,
      alianza: this.alianzaSelected,
      archivo: this.fileToUpload
    }
    console.log(this.outVO);
  }
}

interface CargaMasivaObj {
  tipoDeCargue: string;
  alianza: string;
  archivo: File;
}

so my doubt will be, is creating a POST endpoint in the web api with all the data embedded in an .NET Core FromBody object? If it is, which object type can I use to handle that Angular File object, into a .NET Core File object?

Thakns in advance!

  • You can use `MultipartFormDataContent` for this - https://stackoverflow.com/questions/42212406/how-to-send-a-file-and-form-data-with-httpclient-in-c-sharp/42212590 – Paolo B Oct 02 '18 at 09:18

0 Answers0