public Save ( |
||
image | Bitmap image. | |
maxWidth | int | resize width. |
maxHeight | int | resize height. |
quality | int | quality setting value. |
filePath | string | file path. |
Résultat | void |
private void UploadPartialFile(string fileName, HttpContextBase requestContext, List <ViewDataUploadFilesResult> statuses) { var request = requestContext.Request; 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; String patchOnServer = Path.Combine(StorageRoot); var fullName = Path.Combine(patchOnServer, Path.GetFileName(file.FileName)); var ThumbfullPath = Path.Combine(fullName, Path.GetFileName(file.FileName + ".80x80.jpg")); ImageHandler handler = new ImageHandler(); var ImageBit = ImageHandler.LoadImage(fullName); handler.Save(ImageBit, 80, 80, 10, ThumbfullPath); 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(); } statuses.Add(UploadResult(file.FileName, file.ContentLength, file.FileName)); }
private void UploadPartialFile(string fileName, HttpContextBase requestContext, List<ViewDataUploadFilesResult> statuses) { var request = requestContext.Request; 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; String patchOnServer = Path.Combine(StorageRoot); var fullName = Path.Combine(patchOnServer, Path.GetFileName(file.FileName)); var ThumbfullPath = Path.Combine(fullName, Path.GetFileName(file.FileName + ".80x80.jpg")); ImageHandler handler = new ImageHandler(); var ImageBit = ImageHandler.LoadImage(fullName); handler.Save(ImageBit, 80, 80, 10, ThumbfullPath); 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(); } statuses.Add(UploadResult(file.FileName, file.ContentLength, file.FileName)); }