Copied to clipboard

Flag this post as spam?

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


  • Paul 184 posts 646 karma points
    Jan 30, 2017 @ 13:12
    Paul
    0

    Linking user permission groups to Media folders and files

    Hi all,

    Is there a way to add permissions(the same as are assignable to content nodes) to media folders and files?

    Example of use: Website A has a members section, which registered members can log into. They wish to have documentation which is only visible to those members, so upload files the site for that section.

    Google comes along and indexes the site, including the media files and folders. The URLs are now live on the web, what prevents anyone from seeing the files if they have the URL?

  • David Peck 690 posts 1896 karma points c-trib
    Jan 30, 2017 @ 22:47
    David Peck
    1

    There isn't what you're suggesting. I suggest though that you can either:

    Your surface controller might look like:

    public MediaSurfaceController : SurfaceController
    {
        public ActionResult Download(int id)
        {
              if (User.IsInRole("MyUserRole") == false)
                  return HttpNotFound();
    
              var mediaItem = Umbraco.TypedContent(id);
              string fullName = Server.MapPath(mediaItem.Url);
    
              byte[] fileBytes = GetFile(fullName);
              return File(fileBytes, System.Net.Mime.MediaTypeNames.Application.Octet, fileName);
          }
    
          byte[] GetFile(string s)
          {
              System.IO.FileStream fs = System.IO.File.OpenRead(s);
              byte[] data = new byte[fs.Length];
              int br = fs.Read(data, 0, data.Length);
              if (br != fs.Length)
                  throw new System.IO.IOException(s);
              return data;
          }
      }
    
  • David Peck 690 posts 1896 karma points c-trib
    Jan 30, 2017 @ 22:49
    David Peck
    0

    You'd call that BTW with @Url.Action("Download", "MediaSurface", new {id=1234}) or just <a href="/umbraco/surface/mediaSurface/Download?id=1234">Download</a>

  • Dan Diplo 1554 posts 6205 karma points MVP 6x c-trib
    Jan 30, 2017 @ 23:04
    Dan Diplo
    0

    There's also a (commercial) package that offers this:

    https://our.umbraco.org/projects/website-utilities/media-protect/

  • Paul 184 posts 646 karma points
    Jan 31, 2017 @ 08:30
    Paul
    0

    Thank you gents, I shall investigate these!

  • 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