Created
November 18, 2013 22:43
-
-
Save mookid8000/7536712 to your computer and use it in GitHub Desktop.
Service Azure blob with Web API
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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