开发者

Sitecore.Resources.Media.MediaCreator deletes versions of media

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 ne开发者_JAVA百科w 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.


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜