Copied to clipboard

Flag this post as spam?

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


  • Tom 117 posts 443 karma points
    Sep 29, 2014 @ 11:11
    Tom
    0

    Saving a file with mediaResource.save

    Anyone who knows how to use the mediaResource.save function to save a new file, fx. a pdf?

    The documentation, which can be found here, is not especially detailed. http://umbraco.github.io/Belle/#/api/umbraco.resources.mediaResource

    ...if the media item needs to have files attached, they must be provided as the files param and passed seperately.

    Well, as a bitsteam or as a link or what? How do I pass the files?

  • Jeroen Breuer 4861 posts 12138 karma points MVP 3x admin c-trib
    Sep 29, 2014 @ 12:10
    Jeroen Breuer
    100

    I know that with the API that's behind it all you have to do is this:

    var ms = Services.MediaService;
    var mediaImage = ms.CreateMedia(fileName, parentMediaId, mediaTypeAlias);
    mediaImage.SetValue("umbracoFile", fileName, new MemoryStream(bytes));
    ms.Save(mediaImage);

    So if you pass something in that's a stream it might just work already.

    Jeroen

  • Shane 40 posts 193 karma points
    Dec 05, 2014 @ 11:41
    Shane
    0

    Tom, did you ever find an answer to this?

  • Tom 117 posts 443 karma points
    Dec 05, 2014 @ 12:51
    Tom
    0

    yeah, Jeroens answer more or less worked.

  • Mike B 14 posts 57 karma points
    Nov 29, 2015 @ 19:10
    Mike B
    0

    So there is still no way to do this from a frontend property editor?

  • Karl Tynan 13 posts 145 karma points MVP c-trib
    Mar 08, 2018 @ 14:36
    Karl Tynan
    0

    I'd be interested to know if anyone found out anything more about the angular mediaResource.save() for new media items?

  • This forum is in read-only mode while we transition to the new forum.

    You can continue this topic on the new forum by tapping the "Continue discussion" link below.

Please Sign in or register to post replies