I'm uploading a file via the Request.Files collection along with other data in the Request.Form collection. I start by deleting any previous file and adjusted versions before setting the file:
if (files != null && files["imageFile"] != null)
{
HttpPostedFile file = (HttpPostedFile)files["imageFile"];
var contentLength = file.ContentLength;
if (contentLength > 0)
{
var fileName = file.FileName;
var inputStream = file.InputStream;
byte[] fileData = null;
using (var binaryReader = new System.IO.BinaryReader(inputStream))
{
course.Image.DeleteCachedAdjustments();
course.Image.DeleteFile();
fileData = binaryReader.ReadBytes(contentLength);
course.Image.SetFile(fileData, fileName);
course.UpdateChanges();
}
}
}
I then go ahead and make the other changes:
if (form["imageName"] != null) course.Image.Description = form["imageName"];
After this, I make a final call to UpdateChanges().
When debugging and watching the properties, it all seems good, but when viewing it in WAF afterwards, the description is not persisted.
Why is this? If I only change the description and not the file, everything works fine.