Hi Im wondering if the azure blob service api http://msdn.microsoft.com/en-us/library/dd135733.aspx
can be called using c#. Id like to upload a file e.g a word document to a storage location, the http method is "put" and the rest url is
"http://myaccount.blob.core.windows.net/mycontainer/myblob"
would this code work?
string username = "user"; string password = "password"; string data = "path to word document;
HttpWebRequest request = (HttpWebRequest)WebRequest.Create(url);
request.Method = "PUT";
request.Credentials = new NetworkCredential(username, password);
request.ContentLength = data.Length;
request.ContentType = "text/plain";
using (StreamWriter writer = new StreamWriter(request.GetRequestStream( ))) {
writer.WriteLine(data);
}
WebResponse response = request.GetResponse( );
using (StreamReader reader = new StreamReader(response.GetResponseStream( ))) {
while (reader.Peek( ) != -1) {
Console.WriteLine(reader.ReadLine( ));