Try our conversational search powered by Generative AI!

File upload only works for read-only media

Fixed in

EPiServer.CMS.UI 10.7.1

(Or a related package)

Created

Feb 28, 2017

Updated

Mar 24, 2017

Area

CMS UI

State

Closed, Fixed and tested


Description

If a content item does not implement IReadOnly, or the content provider does not return a read-only instance, then no new binary data will be saved.

Code looks like this inside FileUploadController:

var readOnly = media as IReadOnly;
if (readOnly != null && readOnly.IsReadOnly)
{
   media = (IContentMedia)readOnly.CreateWritableClone();
   media.BinaryData = imageBlob;
}

Workaround: Content providers are expected to return read-only instances, call IReadOnly.MakeReadOnly()

Steps to reproduce:
1) Add TestFile.cs file to Alloy sample site.
2) Upload any *.txt file to media assets. The file should be uploaded correctly.
3) Upload *.txt file with the same name as before, but different file content to same folder.

Expected: The content should be updated with new file data
Actual: The content was not updated