Copied to clipboard

Flag this post as spam?

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


  • Jan van Helvoort 15 posts 71 karma points
    Apr 07, 2014 @ 14:12
    Jan van Helvoort
    0

    Media File stream

    Hi,

    Is it possible to get a file stream from a media item?

    The back-end user upload a PDF File to the media library, With a Media Picker, the same user selects this item to add it to a page.

    From the current page, I get the id of the media item. But now I need a stream so i can edit the file.

    Any idea how I can get this done?

    With kind regards,

    Jan van Helvoort.

  • Rene 2 posts 22 karma points
    Apr 07, 2014 @ 17:33
    Rene
    0

    Hi, what version of Umbraco are you on? For 7+ you can use the Media service like so:

        var media = Services.MediaService.GetById(1072);
    
        var umbracoFilePath = media.GetValue<string>(Umbraco.Core.Constants.Conventions.Media.File);
    
        var path = Server.MapPath(umbracoFilePath);
    
        using (var fs = new FileStream(path, FileMode.Open, FileAccess.Read))
        {
        }
    
  • Jan van Helvoort 15 posts 71 karma points
    Apr 08, 2014 @ 11:15
    Jan van Helvoort
    0

    We are running currently version 6.1.6

    Because of a package we need for this site.

Please Sign in or register to post replies

Write your reply to:

Draft