locked
How to use CloudBlockBlob.OpenReadAsync? RRS feed

  • Question

  • hi,

    can anyone share a sample using CloudBlockBlob.OpenReadAsync method.?

    Friday, November 8, 2013 8:04 AM

Answers

  • Hi PappiG,

    Thanks for posting!

    I suggest you could refer to the offical document (http://msdn.microsoft.com/en-us/library/microsoft.windowsazure.storage.blob.cloudblockblob.openreadasync.aspx). And there is a simple code sample, please refer to :

    HttpResponseMessage message = new HttpResponseMessage(HttpStatusCode.OK);
    Stream blobStream = await cloudBlob.OpenReadAsync();
     
    message.Content = new StreamContent(blobStream);
    message.Content.Headers.ContentLength = cloudBlob.Properties.Length;
    message.Content.Headers.ContentType = new System.Net.Http.Headers.MediaTypeHeaderValue(cloudBlob.Properties.ContentType);
    message.Content.Headers.ContentDisposition = new System.Net.Http.Headers.ContentDispositionHeaderValue("attachment")
    {
        FileName = blobInfo.FileName,
        Size = cloudBlob.Properties.Length
    };
     
    return message;

    Also, you could refer to this page for more detial (http://www.juliencorioland.net/archives/using-aspnet-web-api-to-stream-windows-azure-blobs#.UnzhR_lpkVM ).

    Hope it helps.

    Thanks!

    Regards,

    Will


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    Friday, November 8, 2013 1:11 PM

All replies

  • Hi PappiG,

    Thanks for posting!

    I suggest you could refer to the offical document (http://msdn.microsoft.com/en-us/library/microsoft.windowsazure.storage.blob.cloudblockblob.openreadasync.aspx). And there is a simple code sample, please refer to :

    HttpResponseMessage message = new HttpResponseMessage(HttpStatusCode.OK);
    Stream blobStream = await cloudBlob.OpenReadAsync();
     
    message.Content = new StreamContent(blobStream);
    message.Content.Headers.ContentLength = cloudBlob.Properties.Length;
    message.Content.Headers.ContentType = new System.Net.Http.Headers.MediaTypeHeaderValue(cloudBlob.Properties.ContentType);
    message.Content.Headers.ContentDisposition = new System.Net.Http.Headers.ContentDispositionHeaderValue("attachment")
    {
        FileName = blobInfo.FileName,
        Size = cloudBlob.Properties.Length
    };
     
    return message;

    Also, you could refer to this page for more detial (http://www.juliencorioland.net/archives/using-aspnet-web-api-to-stream-windows-azure-blobs#.UnzhR_lpkVM ).

    Hope it helps.

    Thanks!

    Regards,

    Will


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    Friday, November 8, 2013 1:11 PM
  • Hi, 

    Thanks for the reply. I referred the link shared, but I'm not getting OpenReadASync method. I have included the assembly reference. Im getting OpenRead method. But async method is not shown.

    Doesn't it require to include any other assembly ? 

    Please let me know.


    Thursday, November 14, 2013 9:02 AM
  • Hi PappiG,

    Form document, we may need use those reference:

    CloudBlockBlob Class
    Microsoft.WindowsAzure.Storage.Blob Namespace

    please refer to this page (http://msdn.microsoft.com/en-us/library/microsoft.windowsazure.storage.blob.cloudblockblob_methods.aspx ),See Also part.

    Thanks.

    Will

                         

    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    Thursday, November 14, 2013 9:07 AM