Click here to Skip to main content
15,569,644 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more: , +
I am developing a software in WPF to upload files on amazon cloud. I am able to successfully upload file using httpweb reuqest object. My problem is that when i pause the upload (i have created a pause button) it should be stop uploading at that time, but when i resume the upload, it display the following exception and the upload get suspended.

Unable to write data to the transport connection: An existing connection was forcibly closed by the remote host.

My code is as follows:-
Amazon.S3.AmazonS3 s3Client = new Amazon.S3.AmazonS3Client(AccessKey, SecretKey);
Amazon.S3.Model.GetPreSignedUrlRequest request = new Amazon.S3.Model.GetPreSignedUrlRequest();
request.Verb = Amazon.S3.Model.HttpVerb.PUT;
string url = null;

url = s3Client.GetPreSignedURL(request);
HttpWebRequest httpRequest = WebRequest.Create(url) as HttpWebRequest;
httpRequest.Method = "PUT";
httpRequest.Timeout = -1;
httpRequest.ReadWriteTimeout = -1;
httpRequest.KeepAlive = true;
httpRequest.ProtocolVersion = HttpVersion.Version11;
httpRequest.ServicePoint.ConnectionLimit = 10;
httpRequest.AllowWriteStreamBuffering = false;
httpRequest.ContentLength = FileSize;
Stream writeStream = httpRequest.GetRequestStream();

while (true)
currentPackageSize = stream.Read(buffer, 0, buffer.Length);
if (currentPackageSize > 0)
writeStream.Write(buffer, 0, currentPackageSize);

I need the solution as soon as possible. Thanks in Advance.
Bernhard Hiller 25-Apr-13 5:14am    
That's your upload code. And what's your "pause" code, and what's your "resume" code?

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900