Skip to content

Instantly share code, notes, and snippets.

@mookid8000
Created November 18, 2013 22:43
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 mookid8000/7536712 to your computer and use it in GitHub Desktop.
Save mookid8000/7536712 to your computer and use it in GitHub Desktop.
Service Azure blob with Web API
public async Task<HttpResponseMessage> Get()
{
var blobClient = GetBlobClientFromSomewhere();
var imagesContainer = blobClient.GetContainerReference("images");
var blobRef = await imagesContainer.GetBlobReferenceFromServerAsync(@"cute_cats_70MB.jpg");
var openRead = await blobRef.OpenReadAsync();
var response = new HttpResponseMessage(HttpStatusCode.OK)
{
Content = new StreamContent(openRead)
{
Headers =
{
ContentType = new MediaTypeHeaderValue("image/jpg"),
ContentLength = blobRef.Properties.Length,
}
}
};
return response;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment