コード例 #1
0
ファイル: Form1.cs プロジェクト: CarpDeus/Azure-Commands
        private void btnTestBlocks_Click(object sender, EventArgs e)
        {
            Hashtable ht = new Hashtable();
               string[] AllData = txtMetaData.Text.Split("\n".ToCharArray());
               foreach (string metadataDetail in AllData)
               {
            //string[] detail = metadataDetail.Split(":".ToCharArray());
            string metadataName = string.Empty;
            string metadataValue = string.Empty;
            if (metadataDetail.Contains(":"))
            {
             metadataName = metadataDetail.Substring(0, metadataDetail.IndexOf(":"));
             if (!metadataName.StartsWith("x-ms-meta-"))
              metadataName = "x-ms-meta-" + metadataName;
             if (metadataDetail.Length > metadataDetail.IndexOf(":"))
              metadataValue = metadataDetail.Substring(metadataDetail.IndexOf(":") + 1);
            }
            else
             metadataName = metadataDetail;

            if (metadataName != string.Empty)
            {

             metadataValue = metadataValue.Replace("\r", "");
             if (ht.ContainsKey(metadataName))
              ht[metadataName] = string.Format("{0},{1}", ht[metadataName].ToString(), metadataValue);
             else
              ht.Add(metadataName, metadataValue);
            }
               }

               AzureBlobStorage  abs= new AzureBlobStorage (txtAccount.Text, txtEndpoint.Text, txtSharedKey.Text, "SharedKey");
               string OriginalUrl = string.Format("http://{0}.blob.core.windows.net/{1}/{2}", txtAccount.Text, cbBlobContainers.Text, cbBlobs.Text);
               if (txtBlobLocation.Text.StartsWith("/"))
            txtBlobLocation.Text = txtBlobLocation.Text.Substring(1);
               string newURL = string.Format("http://{0}.blob.core.windows.net/{1}", txtAccount.Text,txtBlobLocation.Text );
               azureResults ar = abs.CopyBlob(OriginalUrl, newURL, ht);
               ar.Succeeded = (ar.StatusCode == System.Net.HttpStatusCode.Created);
        }