Posts

Showing posts from February, 2017

Uploading images using WebApi and JSON

Image
Hi All, I recently had a requirement to create a Web API to work with a mobile phone. I was required to create a method to upload images. So I did it the following way hope you like it. 1) Class Definitions  public class AuthData     {         public string auth_token { get; set; }     }        public class ImageSetData : AuthData     {         public string Name { get; set; }         public List<Image> Images { get; set; }     }     public class Image     {         public string FileName { get; set; }         public string Extension { get; set; }         public byte[] ImageData { get; set; }     } 2) WebApi Method public ReturnMsg SaveFile([FromBody] ImageSetData imageData)         {           ...