lunes, 25 de julio de 2011

CloudBlob.DownloadToFile Method (String)

 

Windows Azure Platform

Downloads the blob's contents to a file.

Namespace: Microsoft.WindowsAzure.StorageClient
Assembly: Microsoft.WindowsAzure.StorageClient (in microsoft.windowsazure.storageclient.dll)

 

Example

static void DownloadBlobToFile(Uri blobEndpoint, string accountName, string accountKey)
{
//Create service client for credentialed access to the Blob service.
CloudBlobClient blobClient = new CloudBlobClient(blobEndpoint, new StorageCredentialsAccountAndKey(accountName, accountKey));

//Return a reference to the blob.
CloudBlob blob = blobClient.GetBlobReference("mycontainer/myblob.txt");

//Download the blob to a local file.
blob.DownloadToFile("c:\\mylocalblob.txt");
}
Community Content

This method uses the default timeout of 90 seconds.   If you download large blobs, and especially if you download them over the Internet (e.g. into a client app), you should probably use the other overload and calculate timeout depending on blob size.   For example:

blob.FetchAttributes(); // Get blob metadata, including length
blob.DownloadToFile(..., new BlobRequestOptions { Timeout = TimeSpan.FromMinutes(Math.Max(1, blob.Properties.Length / 1024*1024)) }); // Allow 1 minute per MB
 
Link http://msdn.microsoft.com/en-us/library/ee772800.aspx

0 comentarios:

Publicar un comentario