Skip to content

Instantly share code, notes, and snippets.

@sircommitsalot
Created April 23, 2014 22:22
Show Gist options
  • Save sircommitsalot/11234551 to your computer and use it in GitHub Desktop.
Save sircommitsalot/11234551 to your computer and use it in GitHub Desktop.
using Microsoft.WindowsAzure.Storage;
using Microsoft.WindowsAzure.Storage.Blob;
using System;
using System.Collections.Generic;
using System.Configuration;
using System.Linq;
using System.Web;
using System.Web.Services;
/// <summary>
/// Summary description for WebService
/// </summary>
[WebService(Namespace = "http://tempuri.org/")]
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
// To allow this Web Service to be called from script, using ASP.NET AJAX, uncomment the following line.
// [System.Web.Script.Services.ScriptService]
public class WebService : System.Web.Services.WebService
{
public WebService()
{
}
[WebMethod]
public string DownloadFileFromBlobToDisk()
{
string path = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData).ToString();
CloudStorageAccount storageAccount = CloudStorageAccount.Parse(
ConfigurationManager.AppSettings["StorageConnectionString"]);
CloudBlobClient blobClient = storageAccount.CreateCloudBlobClient();
CloudBlobContainer container = blobClient.GetContainerReference("info344");
if (container.Exists())
{
foreach (IListBlobItem item in container.ListBlobs(null, false))
{
if (item.GetType() == typeof(CloudBlockBlob))
{
CloudBlockBlob blob = (CloudBlockBlob)item;
string destination = path + "\\" + blob.Name;
blob.DownloadToFile(destination, System.IO.FileMode.Create);
return "Downloaded" + destination;
}
}
}
return "Didn't return shit";
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment