Press Ctrl / CMD + C to copy this to your clipboard.
This post will be reported to the moderators as potential spam to be looked at
I'm using Umbraco v6.1.6 and can't seem to figure out how to create a Media object at level 1, where its parent is the root.
This code returns a new node with Id=0, and I don't know what I'm doing wrong:
IMedia newNode = new Media("name", -1, contentType);
For those who may also struggle with this in the future, use the following:
IMediaService _mediaService = ApplicationContext.Current.Services.MediaService; IMedia newNode = _mediaService.CreateMedia(name, parentId, mediaTypeAlias); ApplicationContext.Current.Services.MediaService.Save(newNode);
The Save() method will do the trick.
but at the root what is the parentId?
is working on a reply...
Write your reply to:
Upload image
Image will be uploaded when post is submitted
How to create Media object at the root of the Media section ?
I'm using Umbraco v6.1.6 and can't seem to figure out how to create a Media object at level 1, where its parent is the root.
This code returns a new node with Id=0, and I don't know what I'm doing wrong:
For those who may also struggle with this in the future, use the following:
The Save() method will do the trick.
but at the root what is the parentId?
is working on a reply...