I'm working on a solution with an AngularJS frontend, which is comunicating over ajax calls with a web server. On the webserver are running some Web API 2 controllers useing the Entity Framework to store data on a sql server. This is working fine except the file upload. I want to use the angular-file-upload to send the image to the webserver and store it on the sql server. But i dont know how to catch the data on the server side, because i cant use the Request Method in my Web API 2 Controller.
My Web API Controller looks like this:
[ResponseType(typeof(Artikel))]
public async Task<IHttpActionResult> PostArtikel(Artikel artikel)
{
if (!ModelState.IsValid)
{
return BadRequest(ModelState);
}
db.Artikels.Add(artikel);
await db.SaveChangesAsync();
return CreatedAtRoute("DefaultApi", new { id = artikel.Id }, artikel);
}
"Artikel" Object
public partial class Artikel
{
public Artikel()
{
this.BestellungArtikels = new HashSet<BestellungArtikel>();
}
public int Id { get; set; }
public string Name { get; set; }
public byte[] Bild { get; set; }