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
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 video Game
-   Renoir [PS4/XOne/PC] Kickstarter Trailer
-   Poly Bridge [PC] Early Access Trailer
-   Renoir [PS4/XOne/PC] Gameplay Explanation Trailer
-   Renoir [PS4/XOne/PC] More About Trailer
-   King's Quest: A Knight to Remember [PS3/PS4/X360/XOne/PC] Complete Collection Trailer
-   Samurai Warriors Chronicles 3 | Announcement Trailer
-   FIFA 16 | No Touch Dribbling with Lionel Messi
-   Why We're Cautiously Optimistic For The Final Fantasy VII Remake
-   Civilization: Beyond Earth – Rising Tide [PC] E3 Gameplay Walkthrough
-   Why We're Excited For the FFVII Remake
-   Mortal Kombat X | Predator Brutality
-   Mortal Kombat X | Predator Fatality
-   Poly Bridge [PC] Early Access Trailer
-   Silence: The Whispered World 2 [PS4/XOne/PC] Cinematic Trailer
-   Devilian [PC] Debut Trailer
Popular tags
Microsoft Access Microsoft Excel Microsoft OneNote Microsoft PowerPoint Microsoft Project Microsoft Visio Microsoft Word Active Directory Biztalk Exchange Server Microsoft LynC Server Microsoft Dynamic Sharepoint Sql Server Windows Server 2008 Windows Server 2012 Windows 7 Windows 8 windows Phone 7 windows Phone 8
programming4us programming4us
 
Popular keywords
HOW TO Swimlane in Visio Visio sort key Pen and Touch Creating groups in Windows Server Raid in Windows Server Exchange 2010 maintenance Exchange server mail enabled groups Debugging Tools Collaborating
programming4us programming4us
PS4 game trailer XBox One game trailer
WiiU game trailer 3ds game trailer
Trailer game
 
programming4us
Heroes Charge
programming4us
Windows Vista
programming4us
Windows 7
programming4us
Windows Azure
programming4us
Windows Server
programming4us
Game Trailer