Quantcast
Channel: VMware Communities : Discussion List - VMware {code}
Viewing all articles
Browse latest Browse all 2738

HTTP Put fails with ESXi 4.1

$
0
0

 

I have c# code that I use to upload files to ESXi 4.0.  The exact same code fails after upgrade to 4.1.  I get this error: "This request requires buffering data to succeed."

 

 

Any suggestions?  I've tried pre-authentication by connecting with the method = "HEAD" (as suggested here: http://support.microsoft.com/kb/908573) but it just hangs.

 

 

url is the url to the ESXi datastore with file path and file name.

 

 

_cookie is the cookie I get from connecting to the ESXi web service before I do the upload.

 

 

HttpWebRequest req = (HttpWebRequest)HttpWebRequest.Create(url);

 

 

req.KeepAlive = false;

 

 

req.SendChunked = true;

 

 

req.Timeout = Timeout.Infinite;

 

 

req.AllowWriteStreamBuffering = false;

 

 

req.PreAuthenticate = true;

 

 

req.Method = "PUT";

 

 

req.Credentials = new NetworkCredential(_login, _password);

 

 

req.Headers.Add(HttpRequestHeader.Cookie, _cookie);

 

 

using (Stream reqStream = req.GetRequestStream())

 

 

{

 

 

// Open the local file

 

 

using (FileStream rdr = new FileStream(_filepath, FileMode.Open, FileAccess.Read, FileShare.Read))

 

 

{

 

 

// Allocate byte buffer to hold file contents

 

 

byte[] inData = new byte[http://Int16.MaxValue|http://Int16.MaxValue];

 

 

int bytesRead;

 

 

long totalBytesRead = 0;

 

 

FileInfo inputFileInfo = new FileInfo(_filepath);

 

 

long totalBytes = inputFileInfo.Length;

 

 

int lastPercent = 0;

 

 

while ((bytesRead = rdr.Read(inData, 0, inData.Length)) != 0)

 

 

{

 

 

reqStream.Write(inData, 0, bytesRead);

 

 

totalBytesRead += bytesRead;

 

 

}

 

 

Array.Resize(ref inData, 0);

 

 

}

 

 

}

 

 

req.GetResponse().Close();

 

 


Viewing all articles
Browse latest Browse all 2738

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>