在下面的代码中,它将通过线路的天蓝色blob流镜像到客户端。 webapi会自动在流上启用压缩,还是需要手动将其添加到BlobResult
操作结果中?
public class BlobResult : IHttpActionResult
{
private readonly CloudBlockBlob blob;
public BlobResult(CloudBlockBlob blob)
{
}
public async Task<HttpResponseMessage> ExecuteAsync(CancellationToken cancellationToken)
{
await blob.FetchAttributesAsync();
var response = new HttpResponseMessage(HttpStatusCode.OK)
{
Content = new StreamContent(await blob.OpenReadAsync())
};
response.Content.Headers.LastModified = blob.Properties.LastModified;
response.Content.Headers.ContentType = new MediaTypeHeaderValue(blob.Properties.ContentType);
return response;
}
}