简体   繁体   中英

ASP.NET MVC - user managment of folder with pictures (FTP?)

i am developing an ASP.NET MVC application and I need a per-user folder with images (including subfolders). I am looking for an easy way to allow managment of such image galerries (folder upload, single image upload, delete, display).

The galery itself isnt the key function of the application and doesnt have to be fancy (no need for comments etc.)

Right now, I am thinking about FTP account for each user. However,

  1. Is there a way to set size limits from c# code to ftp folder?
  2. How would "normal user" upload his image folders? Is there any free plugin wrapping up FTP picture managment?

Or is there a more simpler way?

For the size of a folder, use code

Vb.Net

Dim Klasor As DirectoryInfo = New DirectoryInfo(Server.MapPath("~/Content"))
Dim Boyut As Decimal
For Each dr In Klasor.GetFiles
   Boyut += dr.Length
Next

Vb to C# :(

DirectoryInfo Klasor = new DirectoryInfo(Server.MapPath("~/Content"));
    decimal Boyut = default(decimal);
    foreach (object dr_loopVariable in Klasor.GetFiles) {
        dr = dr_loopVariable;
        Boyut += dr.Length;
    }

Close access to folders on http, Use authorizations membership. Query only accept members own folder. Use authorization to read and write operations..

Sample read : Vb.Net

    Function FileReturn() As FileResult
            Dim fi As New FileInfo(Server.MapPath("~/UserFiles/{UserID}/me.png"))
            Return File(fi.OpenRead, "image/png") 
//and for download Return File(fi.OpenRead, "image/png").FileDownloadName("me.png download") or Return File(fi.OpenRead, "image/png","meee")
        End Function

Convert C# :

public FileResult FileReturn()
{
    FileInfo fi = new FileInfo(Server.MapPath("~/UserFiles/{UserID}/me.png"));
    return File(fi.OpenRead, "image/png");
    //and for download Return File(fi.OpenRead, "image/png").FileDownloadName("me.png download") or Return File(fi.OpenRead, "image/png","meee")
}

I'm sorry for vb.net code

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM