SIGN UP MEMBER LOGIN:    
ARTICLE

Downloading and Saving a File from Windows Azure BLOB Storage

Posted by Dhananjay Kumar Articles | Cloud Computing September 13, 2011
In this post I will show you to download a file from Azure BLOB.
Reader Level:

In this post I will show you to download a file from Azure BLOB.

Set the Connection String as below,

Downloading and saving a File from Windows Azure BLOB storage

Function to download and save file is below,

public void  DownloadFileFromBlob(string fileName, string containerName,string storageConnectionString)

        {
            account = CloudStorageAccount.Parse(RoleEnvironment.

            GetConfigurationSettingValue(storageConnectionString));

            blobClient = account.CreateCloudBlobClient();

            container = blobClient.GetContainerReference(containerName);

            blob = container.GetBlobReference(fileName);

            MemoryStream memStream = new MemoryStream();

            blob.DownloadToStream(memStream);

            Response.ContentType = blob.Properties.ContentType;

            Response.AddHeader("Content-Disposition", "Attachment; filename=" + fileName.ToString());

            Response.AddHeader("Content-Length", blob.Properties.Length.ToString());

            Response.BinaryWrite(memStream.ToArray());           

        }

You need to pass the BLOB name as filename, containerName and connection string to download the file.

Thanks for reading. I hope this post was useful. :)
  

Login to add your contents and source code to this article
share this article :
post comment
 
Nevron Gauge for SharePoint
Become a Sponsor
PREMIUM SPONSORS
  • Finally – a virtual platform that delivers next-generation Windows Server 2008 Hyper-V virtualization technology from a managed hosting partner you can truly depend on. Visit www.maximumasp.com/max for a FREE 30 day trial. Hurry offer ends soon. Climb aboard the MaxV platform and take advantage of High Availability, Intelligent Monitoring, Recurrent Backups, and Scalability – with no hassle or hidden fees. As a managed hosting partner focused solely on Microsoft technologies since 2000, MaximumASP is uniquely qualified to provide the superior support that our business is built on. Unparalleled expertise with Microsoft technologies lead to working directly with Microsoft as first to offer IIS 7 and SQL 2008 betas in a hosted environment; partnering in the Go Live Program for Hyper-V; and product co-launches built on WS 2008 with Hyper-V technology.
    Finally – a virtual platform that delivers next-generation Windows Server 2008 Hyper-V virtualization technology from a managed hosting partner you can truly depend on. Visit www.maximumasp.com/max for a FREE 30 day trial. Hurry offer ends soon. Climb aboard the MaxV platform and take advantage of High Availability, Intelligent Monitoring, Recurrent Backups, and Scalability – with no hassle or hidden fees. As a managed hosting partner focused solely on Microsoft technologies since 2000, MaximumASP is uniquely qualified to provide the superior support that our business is built on. Unparalleled expertise with Microsoft technologies lead to working directly with Microsoft as first to offer IIS 7 and SQL 2008 betas in a hosted environment; partnering in the Go Live Program for Hyper-V; and product co-launches built on WS 2008 with Hyper-V technology.
Become a Sponsor