Welcome Guest! To enable all features please Login or Register.

Notification

Icon
Error

Best practice for file content with authentication support.
cfastner
#1 Posted : Thursday, December 08, 2011 4:10:19 PM(UTC)
Rank: Newbie
Groups: Registered

Joined: 12/7/2011(UTC)
Posts: 9
Hi,
In my current project users can upload multiple files. Where is the best place to store the files? A very crucial point is authentication.
Only the Administrator shoud be allowed to download the files but the ordinary user shoud be allowed to upload his files.

I managed the multiple upload by my own upload page:
Code:
 if (Request.HttpMethod == "POST")
    {
        string firstName = Request.Form["firstName"];
        string lastName = Request.Form["lastname"];
        string userFolder = firstName + "_" + lastName;


        foreach (string file in Request.Files)
        {
            HttpPostedFileBase hpf = Request.Files[file] as HttpPostedFileBase;

            if (hpf.ContentLength == 0)
            {
                continue;
            }

            string savedFileName = "";
            
            if (String.IsNullOrEmpty(userFolder.Replace("_", "")))
            {

                savedFileName = Path.Combine(AppDomain.CurrentDomain.BaseDirectory + "/Cms_Data/Contents/Kooboo_CMS/Media/Bewerbungen/", Path.GetFileName(hpf.FileName) + "_" + DateTime.Now.ToString("yyyy.MM.dd hh:mm:ss"));
            }
            else
            {
                string folderPath = AppDomain.CurrentDomain.BaseDirectory + "/Cms_Data/Contents/Kooboo_CMS/Media/Bewerbungen/" + userFolder;
                System.IO.Directory.CreateDirectory(folderPath);
                savedFileName = Path.Combine(folderPath + "/", userFolder + "_" + Path.GetFileName(hpf.FileName));
            }


            hpf.SaveAs(savedFileName);

        }

    }


One way I can think of is to have a upload folder and then copy the files to a secured folder.
I'm also very new to kooboo and razor mvc3, so code examples would be very appreciated.
What's the best practice for that requirement?

thx a lot!
jifeng
#2 Posted : Friday, December 09, 2011 6:29:38 AM(UTC)
Rank: Administration
Groups: Administrators, Registered

Joined: 9/3/2009(UTC)
Posts: 1,555
Location: Xiamen China
Using the MediaContentManager api to upload the files into the media library, then the administrators can download the files from the cms panel.
Regards,

Jifeng Huang

Kooboo Team

Microsoft ASP.NET MVP
sbrickey
#3 Posted : Wednesday, December 21, 2011 3:03:52 AM(UTC)
Rank: Advanced Member
Groups: Registered

Joined: 12/16/2011(UTC)
Posts: 35
Location: Ohio, USA
or use a view to handle uploads and listing contents... allow any user to upload, but filter the display of files based on a role.
Users browsing this topic
Guest
Forum Jump  
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.

Powered by YAF 1.9.5.5 | YAF © 2003-2011, Yet Another Forum.NET
This page was generated in 0.439 seconds.