Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at

  • Hefin Jones 39 posts 161 karma points
    Dec 01, 2014 @ 11:08
    Hefin Jones

    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:

    var mediaService = Services.MediaService;
    var mediaImage = mediaService.CreateMedia("test4", 1152, "Image");
    mediaImage.SetValue("umbracoFile", test, fileStream);

    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!


  • Sebastiaan Janssen 5053 posts 15507 karma points MVP admin hq
    Dec 01, 2014 @ 11:27
    Sebastiaan Janssen

    Just remove "test,".. ;-)

    mediaImage.SetValue("umbracoFile", fileStream);

Please Sign in or register to post replies

Write your reply to: