using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Web.UI; using System.Web.UI.WebControls; using Windows.Azure.Storage; using System.Xml.Linq; using System.Net; namespace PhotoStore_WebRole { public partial class ManageBlob : System.Web.UI.Page { private ConnectionDetails connectionDetails; private string blobFullPath; private string blob; private string container; protected void Page_Load(object sender, EventArgs e) { connectionDetails = PhotoStoreUtils.GetConnectionDetails(); blobFullPath = Request.QueryString["blob"]; ProcessBlobElements(); if (!IsPostBack) { SetPictureDetails(); } } private void ProcessBlobElements() { string[] urlBits; urlBits = new Uri(blobFullPath).PathAndQuery.Split('/'); container = urlBits[urlBits.Length - 2]; blob = urlBits[urlBits.Length - 1]; } private void SetPictureDetails() { imgBlob.ImageUrl = blobFullPath; LoadMetadata(); } private void LoadMetadata() { BlobContainer request = new BlobContainer(connectionDetails, container); BlobContainerResponse response; response = request.GetBlobMetadata(blob); if (response.ResponseCode == System.Net.HttpStatusCode.OK) { txtDescription.Text = response.ResponseHeaders["x-ms-meta-description"]; } } protected void btnSetMetadata_Click(object sender, EventArgs e) { Dictionary metadata = new Dictionary() ; BlobContainer request = new BlobContainer(connectionDetails, container); BlobContainerResponse response; metadata.Add("x-ms-meta-description", txtDescription.Text); response = request.SetBlobMetadata(blob, metadata); using (Label status = new Label()) { if (response.ResponseMessage == "OK") { status.Text = "Updated Successful"; status.ForeColor = System.Drawing.Color.Green; } else { status.Text = String.Format("{0}: {1}", "Error", response.ResponseBody); status.ForeColor = System.Drawing.Color.Red; } phStatus.Controls.Add(status); } } } }