Logo
programming4us
programming4us
programming4us
programming4us
Home
programming4us
XP
programming4us
Windows Vista
programming4us
Windows 7
programming4us
Windows Azure
programming4us
Windows Server
programming4us
Windows Phone
 
Windows Azure

Downloading BLOBs

3/5/2011 4:05:52 PM
- Free product key for windows 10
- Free Product Key for Microsoft office 365
- Malwarebytes Premium 3.7.1 Serial Keys (LifeTime) 2019
In this section we’ll look at how to download BLOBs from both a public container and a private container. To take things nice and easy, we’ll tell you how to download BLOBs that are stored in a public container first.

1. Downloading BLOBs from a public container

If your BLOB is hosted in a public container, you can present the URI of the BLOB directly to the user and they’ll be able to directly download the file to their browser. In our podcasting sample, the following URI will download podcast01.wma from the ChrisConverted public container in the development storage account: http://127.0.0.1:10000/devstoreaccount1/ChrisConverted/podcast01.wma. Because the BLOB is held in a public container, the user won’t need to provide any credentials to access the BLOB.

Tip

If you’ve correctly set the MIME type of your podcast, when the URI is pasted into your browser, the podcast will automatically start playing in Windows Media Player.


In our management web page example, we don’t want to expose the podcasts to the world; we want to restrict access to our own credentials. Let’s look at how you can do that using your new best friend, the storage client.

2. Downloading BLOBs from a private container using the storage client

Now we want you to modify your management web page so that if you click the View button for the selected podcast, as shown in figure 9.5, you’re prompted to download the file (also shown in figure 1).

Figure 1. Clicking the View button on your BLOBs page opens a Save dialog box


Although you can store the BLOB in a public container to achieve the same result, in this example you’re going to first download the BLOB to your web role and then serve the BLOB from your web role, rather than directly from BLOB storage.

In this listing, we defined the ASPX for your View button; listing 1 is where we hook up the code that will download the file when this button is clicked. The code in the following listing will download the selected BLOB and prompt the user with the Save dialog box shown in figure 1.

Listing 9.7. Downloading BLOBs from the grid using the storage client

At you create a new memory stream that writes the contents of the BLOB that’s been downloaded from BLOB storage. At you set the MIME type of the file so that you can allow the browser to perform the correct action based on that type (for example, launch Windows Media Player, Microsoft Word, or some other action), and you add the content-disposition header so that the browser knows to offer a Save file dialog box to the user. Finally, the downloaded BLOB is made available to the client by writing the file to the response stream .

Tip

In the previous example, we used the DownloadToStream option to download files from BLOB storage but the storage client also offers these methods to download files: DownloadText, DownloadByteArray, and DownloadToFile.


So far we’ve shown you how to download files that are in public or private containers. What if you want to do something a little more granular, like control access to your BLOBs or containers? For operations like this, you can use a Shared Access Signature. Later on, we’ll look at this feature in a little more detail.

Now that you know how to upload and download BLOBs, let’s look at how you can integrate BLOB storage with your existing ASP.NET websites.

Other -----------------
- Managing BLOBs using the StorageClient library (part 2) - Uploading BLOBs & Deleting BLOBs
- Managing BLOBs using the StorageClient library (part 1) - Listing BLOBs using the storage client
- Using the REST API (part 2) - Authenticating private requests
- Using the REST API (part 1) - Listing BLOBs in a public container using REST
- The basics of BLOBs - Configuring your application to work against the live service
- The basics of BLOBs : Developing against containers (part 3) - Listing containers & Deleting a container
- The basics of BLOBs : Developing against containers (part 2) - Creating a container
- The basics of BLOBs : Developing against containers (part 1) - Accessing the StorageClient library & Accessing development storage
- The basics of BLOBs : Getting started with development storage
- A closer look at the BLOB storage service
 
 
Top 10
- Microsoft Visio 2013 : Adding Structure to Your Diagrams - Finding containers and lists in Visio (part 2) - Wireframes,Legends
- Microsoft Visio 2013 : Adding Structure to Your Diagrams - Finding containers and lists in Visio (part 1) - Swimlanes
- Microsoft Visio 2013 : Adding Structure to Your Diagrams - Formatting and sizing lists
- Microsoft Visio 2013 : Adding Structure to Your Diagrams - Adding shapes to lists
- Microsoft Visio 2013 : Adding Structure to Your Diagrams - Sizing containers
- Microsoft Access 2010 : Control Properties and Why to Use Them (part 3) - The Other Properties of a Control
- Microsoft Access 2010 : Control Properties and Why to Use Them (part 2) - The Data Properties of a Control
- Microsoft Access 2010 : Control Properties and Why to Use Them (part 1) - The Format Properties of a Control
- Microsoft Access 2010 : Form Properties and Why Should You Use Them - Working with the Properties Window
- Microsoft Visio 2013 : Using the Organization Chart Wizard with new data
 
programming4us
Windows Vista
programming4us
Windows 7
programming4us
Windows Azure
programming4us
Windows Server