User Galleries

Suneel Jhangiani asked on July 18, 2018 14:33

I currently have a requirement to build a site that allows users to upload their own images, video and audio which are then visible to other members.

Initially I was thinking I would just create a Media Library for each user, with some sub folders to hold the various media types. However, I believe to get security right for this I would have to create a role for each user so that they have permission to upload and create items only in their library.

Therefore, I wanted to know if anyone has any other suggestions as to how to implement this?

Correct Answer

Trevor Fayas answered on July 18, 2018 16:36

Some things to think about.

You may not need special permissions for each user/group for the media library if they don't have Editor status (can't access the Kentico CMS admin area), even a unique media library for each user.

If they don't have Kentico admin accesses, one simple solution would be to have a single Media Library ("User Uploaded Content"), with either of these structures:

-UserUploadedContent
  -Images
     -Bob
  -Videos
     -Bob
  -Audio
     -Bob

 OR

 -UserUploadedContent
   -Bob
      -Images
      -Videos
      -Audio

Then all you need to do is create a page where they can upload a file, and you programatically (using the API) place the file in the proper folder using their username. They can't Edit / Delete, right? so this makes it easy.

If they do need Delete capabilities, again you could just do this with a custom screen, Repeat all files found in the path matching their username, and provide a Delete button control that will delete that file (again using the API).

Does this solve it, or do they have Admin access?

0 votesVote for this answer Unmark Correct answer

Recent Answers


Peter Mogilnitski answered on July 18, 2018 17:46 (last edited on July 18, 2018 18:25)

You create one media library and one role and assign users to this role. No need for amdin rights. For ex. create a role called 'MediaLibraryUploader'. Now go your media library, set permssions for this role (I just set one, but you can set what you need). Theoretically a problem with this approach is that other users who are members of this role can delete files that they did not upload. I guess since each uploaded file (see Media_File table) has userid (column called FileCreatedByUserID) - you can display files on your page that belong to this user only, so each user can see only his files.

P.S. There is a couple web parts you might consider: media uploader and media gallery.

0 votesVote for this answer Mark as a Correct answer

Suneel Jhangiani answered on July 19, 2018 13:06

Trevor,

Thanks for providing that and pointing me in the right direction. You are right in that users will not have admin / editor access, so a single media library with subfolders makes good sense.

0 votesVote for this answer Mark as a Correct answer

Suneel Jhangiani answered on July 27, 2018 16:40

Trevor,

Further to your advice I set-up the structure so that its one media library and subfolders in the form "Root/{UserName}/{MediaType}".

What I'd like to do now is add a MediaLibrary File editor to the back end when administering users. It's easy to add a new UI Page based on the 'Library_Edit_Files.aspx' that is used by the 'Content Management / Media libraries'. However, this shows all the usernames subfolders and I'd like to know if there is either a field I can use to set the starting path, or if I should be looking at using another control?

0 votesVote for this answer Mark as a Correct answer

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