Apply permissions for a mediafile for particular user

Naresh Ede asked on June 16, 2018 14:14

Hi Guys

I have a form in my site, and the user can upload the supported document using fileupload. I want to store the file in media library, it should be secured and it can be accessible by the submitted user and an admin role.

How can we achieve this ? Is that possible to apply permissions for individual files in a media library?

Thanks

Naresh Ede

Recent Answers


Peter Mogilnitski answered on June 16, 2018 22:52 (last edited on June 16, 2018 23:43)

For individual files it is not possible (and does not make any sense). You can apply permission at the media library level. Why do you need to store file in media library first of all? You have it perfectly stored in the form record and physical folder. Files are physically stored bizformfiles folder And to get it, you use: ~/Kentico11/CMSPages/GetBizFormFile.aspx?filename=[fileColumnName]. The fileColumnName value has GUID in it that makes it unique. Unless someone gives you this URL you cannot make it yourself. What sort of security you are talking about?

0 votesVote for this answer Mark as a Correct answer

Naresh Ede answered on June 17, 2018 17:00

Thanks Peter,

Suppose the user submitted his passport copy. so the document can be accessed by the submitted user and admin as well.

If the anonymous user has the URL of file, he can not able to view the file.

Whats the best solution other than storing the files in media libraries?

Regards

Naresh Ede

0 votesVote for this answer Mark as a Correct answer

Peter Mogilnitski answered on June 17, 2018 22:40 (last edited on June 17, 2018 23:09)

Why are you keep saying media libraries? By default the form files stored not in media library folder, they are stored ~/<site code name>/BizFormFiles. If you want to protect a folder udner IIS you can protect it by disabling anonymous access at the IIS level:

  1. Run IIS and select your folder in the tree
  2. Click authentication: Image Text
  3. Click Disable: Image Text

Make sure as well that directory browsing is disabled at the IIS level.

These 2 thing should be suffice. You don't need media library for that.

0 votesVote for this answer Mark as a Correct answer

   Please, sign in to be able to submit a new answer.