My current web API already responding JSON data as below.
public HttpResponseMessage GetFieldInfo()
{
//....
return Ok(GetFieldsInstance()); //GetFieldsInstance returning with DTO class instance.
}
Now, I need to include, file along with JSON response. I could not find any link which shows, how to include filestream and JSON in single response.
For file stream, it will work as below but, not able to find way, how to include JSON object property with filestream.
result = Request.CreateResponse(HttpStatusCode.OK);
result.Content = new StreamContent(new FileStream(localFilePath, FileMode.Open, FileAccess.Read));
result.Content.Headers.ContentDisposition = new System.Net.Http.Headers.ContentDispositionHeaderValue("attachment");
result.Content.Headers.ContentDisposition.FileName = "FieldFile";