Reputation: 57
I want to add a image using contentservice in umbraco , can it bo done simply using setValue method, what do I need to pass to the setValue Method?
Upvotes: 0
Views: 855
Reputation: 3437
You should use the MediaService instead of the contentservice.
// check ApplicationContext.Current != null
var ms = ApplicationContext.Current.Services.MediaService;
var newMediaItem = ms.CreateMedia(file.FileName, <parentId>, Constants.Conventions.MediaTypes.Image);
newMediaItem.SetValue(Constants.Conventions.Media.File, file);
ms.Save(newMediaItem);
Upvotes: 1