I'm trying to create media programmatically, I've seen numerous examples of how it's done which all seem logical - I can create the media item fine - but I can't upload a file to the media item at the same time. I see examples similar to this:
var mediaService = Services.MediaService; var mediaImage = mediaService.CreateMedia("test4", 1152, "Image"); mediaImage.SetValue("umbracoFile", test, fileStream); mediaService.Save(mediaImage);
But when I try to use the "mediaService.Save" method, I don't have an overload which accepts a File Stream as part of the Save - is this still available in Umbraco 7? I keep getting the error "No overload for method 'SetValue' takes 3 arguments"
Creating and Saving Media Programmatically
Hello guys,
I'm trying to create media programmatically, I've seen numerous examples of how it's done which all seem logical - I can create the media item fine - but I can't upload a file to the media item at the same time. I see examples similar to this:
But when I try to use the "mediaService.Save" method, I don't have an overload which accepts a File Stream as part of the Save - is this still available in Umbraco 7? I keep getting the error "No overload for method 'SetValue' takes 3 arguments"
Any help would be greatly appreciated!
Cheers!
Just remove "test,".. ;-)
mediaImage.SetValue("umbracoFile", fileStream);
is working on a reply...