Skip to content

Instantly share code, notes, and snippets.

@arn-e
Last active August 29, 2015 14:16
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save arn-e/d405b8e85fce60d4607f to your computer and use it in GitHub Desktop.
Save arn-e/d405b8e85fce60d4607f to your computer and use it in GitHub Desktop.
[HttpGet]
public HttpResponseMessage ReadWidget(long id)
{
WidgetBusiness widgetBusiness = new WidgetBusiness();
Widget widget = widgetBusiness.Get(id);
HttpResponseMessage response = new HttpResponseMessage();
response.Content = new ByteArrayContent(widget.Data);
response.Content.Headers.ContentDisposition = new System.Net.Http.Headers.ContentDispositionHeaderValue("attachment");
response.Content.Headers.ContentDisposition.FileName = widget.Id.ToString();
response.Content.Headers.ContentType = new System.Net.Http.Headers.MediaTypeHeaderValue("application/jpg");
return response;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment