Sitecore.Resources.Media.MediaCreator deletes versions of media

与世无争的帅哥 提交于 2019-12-24 08:32:06

问题


I am adding images to the Media Library using the "Sitecore.Resources.Media.MediaCreator" and the "CreateFromStream"-function. Everything seems to work fine except that everytime I add a new image to an already existing image item the old image is overwritten, I would like to create a new version instead and add the new image to the new version, keeping the old version and image. The images should be based on an "unversioned" template as images are shared between languages.

I have tried programmatically adding a new version prior to adding new media but the new version is deleted after running CreateFromStream().

I have also tried the different MediaCreatorOptions "Versioned" and "KeepExisting" but it doesn't help me.

It is possible to do this using SheerUI so I guess it should be possible.

I would really appreciate any help.


回答1:


I think I solved it.

Media media = MediaManager.GetMedia(myOldMediaItem);
media.SetStream(memoryStream, extension);

This code does not delete any previous versions, off course I need to add the new versions before.



来源:https://stackoverflow.com/questions/5734834/sitecore-resources-media-mediacreator-deletes-versions-of-media

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!