diff --git a/jQuery-File-Upload.MVC3/Controllers/HomeController.cs b/jQuery-File-Upload.MVC3/Controllers/HomeController.cs index 463d058..384917d 100644 --- a/jQuery-File-Upload.MVC3/Controllers/HomeController.cs +++ b/jQuery-File-Upload.MVC3/Controllers/HomeController.cs @@ -91,24 +91,15 @@ private string EncodeFile(string fileName) private void UploadPartialFile(string fileName, HttpRequestBase request, List statuses) { if (request.Files.Count != 1) throw new HttpRequestValidationException("Attempt to upload chunked file containing more than one fragment per request"); - var file = request.Files[0]; - var inputStream = file.InputStream; + var file = request.Files[0]; var fullName = Path.Combine(StorageRoot, Path.GetFileName(fileName)); using (var fs = new FileStream(fullName, FileMode.Append, FileAccess.Write)) { - var buffer = new byte[1024]; - - var l = inputStream.Read(buffer, 0, 1024); - while (l > 0) - { - fs.Write(buffer, 0, l); - l = inputStream.Read(buffer, 0, 1024); - } - fs.Flush(); - fs.Close(); + file.InputStream.CopyTo(fs); } + statuses.Add(new ViewDataUploadFilesResult() { name = fileName, diff --git a/jQuery-File-Upload.MVC3/Upload/UploadHandler.ashx.cs b/jQuery-File-Upload.MVC3/Upload/UploadHandler.ashx.cs index 4d45757..638adcc 100644 --- a/jQuery-File-Upload.MVC3/Upload/UploadHandler.ashx.cs +++ b/jQuery-File-Upload.MVC3/Upload/UploadHandler.ashx.cs @@ -108,16 +108,7 @@ private void UploadPartialFile(string fileName, HttpContext context, List 0) - { - fs.Write(buffer, 0, l); - l = inputStream.Read(buffer, 0, 1024); - } - fs.Flush(); - fs.Close(); + inputStream.CopyTo(fs); } statuses.Add(new FilesStatus(new FileInfo(fullName))); } @@ -194,4 +185,4 @@ private void ListCurrentFiles(HttpContext context) } } -} \ No newline at end of file +}