I'm using angular app with .net core backend.
What I want to do, is to do a simple file upload app.
To c# controller I'm sending this json:
{"name":"test","extension":".txt","dateCreated":"2017-12-11T10:59:19.156Z","dateModified":"2017-12-11T10:59:19.156Z","data":{"0":89,"1":13,"2":10,"3":49,"4":48,"5":48,"6":13,"7":10,"8":69,"9":13,"10":10,"11":89,"12":13,"13":10,"14":53,"15":48,"16":13,"17":10,"18":72}}
It is formed by this TS class
export class File {
id: number;
name: string;
data: Uint8Array;
dateCreated: Date;
dateModified: Date;
extension: string;
}
Controller looks like
// POST: api/Test/Files
[HttpPost("[action]")]
public async Task<IActionResult> Files([FromBody] Files file)
And my Files class looks like
public partial class Files
{
public int id { get; set; }
public string name { get; set; }
public byte[] data { get; set; }
public DateTime dateCreated { get; set; }
public DateTime dateModified { get; set; }
public string extension { get; set; }
}
Response I'm getting:
{
"data.0": [
"The input was not valid."
]
}
I think the problem is that my controller can't convert from Uint8Array to byte[], but I cant seem to find the solution.