{"action":"created","issue":{"url":"https://api.github.com/repos/restsharp/RestSharp/issues/742","labels_url":"https://api.github.com/repos/restsharp/RestSharp/issues/742/labels{/name}","comments_url":"https://api.github.com/repos/restsharp/RestSharp/issues/742/comments","events_url":"https://api.github.com/repos/restsharp/RestSharp/issues/742/events","html_url":"https://github.com/restsharp/RestSharp/issues/742","id":103042000,"number":742,"title":"Issue uploading files (sync)","user":{"login":"wing328","id":934260,"avatar_url":"https://avatars.githubusercontent.com/u/934260?v=3","gravatar_id":"","url":"https://api.github.com/users/wing328","html_url":"https://github.com/wing328","followers_url":"https://api.github.com/users/wing328/followers","following_url":"https://api.github.com/users/wing328/following{/other_user}","gists_url":"https://api.github.com/users/wing328/gists{/gist_id}","starred_url":"https://api.github.com/users/wing328/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/wing328/subscriptions","organizations_url":"https://api.github.com/users/wing328/orgs","repos_url":"https://api.github.com/users/wing328/repos","events_url":"https://api.github.com/users/wing328/events{/privacy}","received_events_url":"https://api.github.com/users/wing328/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":5,"created_at":"2015-08-25T15:03:06Z","updated_at":"2015-11-02T18:05:02Z","closed_at":null,"body":"With the latest version of RestSharp (105.2.2), I ran into an issue uploading a file with the following error message:\r\n```\r\nError: System.Net.WebException: Request was cancelled. ---> System.IO.IOException: Cannot close the stream until all bytes are written\r\n  --- End of inner exception stack trace ---\r\n  at System.Net.WebConnectionStream.Close () [0x00183] in /private/tmp/source-mono-mac-4.0.0-branch-c5sr3/bockbuild-mono-4.0.0-branch/profiles/mono-mac-xamarin/build-root/mono-4.0.3/mcs/class/System/System.Net/WebConnectionStream.cs:821 \r\n  at System.IO.Stream.Dispose () [0x00000] in /private/tmp/source-mono-mac-4.0.0-branch-c5sr3/bockbuild-mono-4.0.0-branch/profiles/mono-mac-xamarin/build-root/mono-4.0.3/external/referencesource/mscorlib/system/io/stream.cs:260 \r\n  at RestSharp.Http.WriteRequestBody (System.Net.HttpWebRequest webRequest) [0x00000] in <filename unknown>:0 \r\n  at RestSharp.Http.PostPutInternal (System.String method) [0x00000] in <filename unknown>:0 \r\n  at RestSharp.Http.AsPost (System.String httpMethod) [0x00000] in <filename unknown>:0 \r\n  at RestSharp.RestClient.DoExecuteAsPost (IHttp http, System.String method) [0x00000] in <filename unknown>:0 \r\n  at RestSharp.RestClient.Execute (IRestRequest request, System.String httpMethod, System.Func`3 getResponse) [0x00000] in <filename unknown>:0 \r\n```\r\nUsing an older version of RestSharp (105.1.0), I was able to upload the file without issue. Here is the code to repeat the issue.\r\n```\r\nusing System;\r\nusing RestSharp;\r\nusing RestSharp.Extensions;\r\nusing System.IO;\r\n\r\nnamespace UploadTest\r\n{\r\n\tclass MainClass\r\n\t{\r\n\t\tpublic static void Main (string[] args)\r\n\t\t{\r\n\t\t\tvar client = new RestClient(\"http://petstore.swagger.io/v2/\");\r\n\t\t\tvar request = new RestRequest(\"pet/{petId}/uploadImage\", Method.POST);\r\n\t\t\trequest.AddUrlSegment(\"petId\", \"2\"); // replaces matching token in request.Resource\r\n\r\n\t\t\tFileStream stream = new FileStream (\"/var/tmp/1.txt\", FileMode.Open);\r\n\r\n\t\t\tvar fileParam = FileParameter.Create(\"file\", stream.ReadAsBytes(), Path.GetFileName(((FileStream)stream).Name));\r\n\t\t\trequest.AddFile(fileParam.Name, fileParam.Writer, fileParam.FileName, fileParam.ContentType);\r\n\t\t\t// execute the request\r\n\t\t\tIRestResponse response = client.Execute(request);\r\n\r\n\t\t\tif (response.ErrorException != null)\r\n\t\t\t{\r\n\t\t\t\tConsole.WriteLine(\"Error: \" + response.ErrorException);\r\n\t\t\t}\r\n\t\t\t\t\r\n\t\t\tConsole.WriteLine (\"content=\" + response.Content);\r\n\t\t}\r\n\t}\r\n}\r\n```\r\nHas anyone run into similar issue?\r\n\r\n"},"comment":{"url":"https://api.github.com/repos/restsharp/RestSharp/issues/comments/153103792","html_url":"https://github.com/restsharp/RestSharp/issues/742#issuecomment-153103792","issue_url":"https://api.github.com/repos/restsharp/RestSharp/issues/742","id":153103792,"user":{"login":"hallem","id":1198158,"avatar_url":"https://avatars.githubusercontent.com/u/1198158?v=3","gravatar_id":"","url":"https://api.github.com/users/hallem","html_url":"https://github.com/hallem","followers_url":"https://api.github.com/users/hallem/followers","following_url":"https://api.github.com/users/hallem/following{/other_user}","gists_url":"https://api.github.com/users/hallem/gists{/gist_id}","starred_url":"https://api.github.com/users/hallem/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/hallem/subscriptions","organizations_url":"https://api.github.com/users/hallem/orgs","repos_url":"https://api.github.com/users/hallem/repos","events_url":"https://api.github.com/users/hallem/events{/privacy}","received_events_url":"https://api.github.com/users/hallem/received_events","type":"User","site_admin":false},"created_at":"2015-11-02T18:05:01Z","updated_at":"2015-11-02T18:05:01Z","body":"Thanks for the PR on this as well.  I'll get it reviewed an merged in ASAP."}}