The
resized.Save
method advances the current position of the
imageStream
by the number of bytes written.
The
imageBytes.CopyTo
method copies the bytes
from the current position to the end of the stream.
Since the current position is already at the end of the stream, there is nothing to copy. You need to reset the current position before copying:
if (MyUploader is null) return new ObjectResult(new { status = "fail" });
using var image = System.Drawing.Image.FromStream(MyUploader.OpenReadStream());
using var resized = new Bitmap(image, new System.Drawing.Size(150, 150));
using var imageStream = new MemoryStream();
resized.Save(imageStream, ImageFormat.Jpeg);
string uploadsFolder = @"\\10.10.10.67\AQSImages\IdPictures\";
string filePath = Path.Combine(uploadsFolder, MyUploader.FileName);
using var fileStream = new FileStream(filePath, FileMode.Create);
imageStream.Seek(0L, SeekOrigin.Begin);
imageStream.CopyTo(fileStream);
return new ObjectResult(new { status = "success" });