WebUploader téléchargements de fichiers volumineux et des exemples de code détaillés

Dossier logique de traitement de base de données

DbFolder public class

{

    racine JSONObject;

   

    DbFolder publique ()

    {

        this.root = new JSONObject ();

        this.root.put ( "F_ID", "");

        this.root.put ( "f_nameLoc", "根 目录");

        this.root.put ( "f_pid", "");

        this.root.put ( "f_pidRoot", "");

    }

   

    / **

     * Le JSONArray converti en carte

     * dossiers @param

     * @revenir

     * /

    Carte publique <String, JSONObject> Todic (dossiers JSONArray)

    {

        Carte <String, JSONObject> dt = new HashMap <String, JSONObject> ();

        pour (int i = 0, l = folders.size (); i <l; i ++)

        {

            JSONObject o = folders.getJSONObject (i);

            Chaîne id = o.getString ( "F_ID");

            dt.put (id, o);

        }

        retourner dt;

    }

   

    Carte publique <String, JSONObject> foldersToDic (String pidRoot)

    {

        // charger le répertoire racine par défaut

        Chaîne SQL = String.format ( "select F_ID, f_nameLoc, f_pid, f_pidRoot de up6_folders où f_pidRoot = '% s'", pidRoot);

 

        SQLEXEC SE = new SQLEXEC ();

        JSONArray dossiers = se.exec ( "up6_folders", sql, "F_ID, f_nameLoc, f_pid, f_pidRoot", "");

        retourner this.toDic (dossiers);

    }

   

    publique ArrayList <JSONObject> sortByPid (Carte <String, JSONObject> dt, String idCur, ArrayList <JSONObject> PSORT) {

 

        Chaîne cur = idCur;

        while (true)

        {

            // clé n'existe pas

            si (dt.containsKey (roquet)!) la rupture;

 

            JSONObject D = dt.get (cur); // vérifier l'ID de parent

            psort.add (0, d); // surface supérieure du noeud parent           

            = cabot d.getString ( "f_pid") trim () ;. // prendre l'ID parent

 

            if (cur.trim () == "0") break;

            if (StringUtils.isBlank (cur)) break;

        }

        retourner PSORT;

    }

   

 

    publique JSONArray build_path_by_id (JSONObject fdCur) {

 

        Chaîne id = fdCur.getString ( "F_ID") trim ();. //

        Chaîne pidRoot = fdCur.getString ( "f_pidRoot") trim ();. //

 

        // répertoire racine

        ArrayList <JSONObject> PSORT = new ArrayList <JSONObject> ();

        if (StringUtils.isBlank (id))

        {

            psort.add (0, this.root);

 

            retour JSONArray.fromObject (PSORT);

        }

 

        // table de mappage de répertoire de construction (id, dossier)

        Carte <String, JSONObject> dt = this.foldersToDic (pidRoot);

 

        // hiérarchisés catalogue de commande

        PSORT = this.sortByPid (dt, id, PSORT);

 

        SQLEXEC SE = new SQLEXEC ();

        // est un sous-répertoire -> Ajouter répertoire racine

        if (! StringUtils.isBlank (pidRoot))

        {

            JSONObject root = se.read ( "up6_files"

                    , "F_ID, f_nameLoc, f_pid, f_pidRoot"

                    , Nouveau SqlParam [] {new SqlParam ( "F_ID", pidRoot)});

            psort.add (0, racine);

        } // répertoire racine -> Ajouter un répertoire racine

        else if (! StringUtils.isBlank (id) && StringUtils.isBlank (pidRoot))

        {

            JSONObject root = se.read ( "up6_files"

                    , "F_ID, f_nameLoc, f_pid, f_pidRoot"

                    , Nouveau SqlParam [] {new SqlParam ( "F_ID", id)});

            psort.add (0, racine);

        }

        psort.add (0, this.root);

 

        retour JSONArray.fromObject (PSORT);

    }

   

    publique FileInf lu (id String) {

        SQLEXEC SE = new SQLEXEC ();

        Chaîne SQL = String.format ( "sélectionner f_pid, f_pidRoot, f_pathSvr de up6_files où F_ID = '% s' union sélectionner f_pid, f_pidRoot, f_pathSvr de up6_folders où F_ID = '% s'", id, id);

        données JSONArray = se.exec ( "up6_files", SQL, "f_pid, f_pidRoot, f_pathSvr", "");

        JSONObject o = (JSONObject) data.get (0);

 

        fichier FileInf = new FileInf ();

        file.id = id;

        file.pid = o.getString ( "f_pid") trim ().

        file.pidRoot = o.getString ( "f_pidRoot") trim ().

        file.pathSvr = o.getString ( "f_pathSvr") trim ().

        fichier retourner;

    }

   

    Boolean publique exist_same_file (String name, String pid)

    {

        SqlWhereMerge nouveau montant de SqlWhereMerge = ();

        swm.equal ( "f_nameLoc", name.trim ());

        swm.equal ( "f_pid", pid.trim ());

        swm.equal ( "f_deleted", 0);

 

        Chaîne SQL = String.format ( "sélectionner F_ID de up6_files où% s", swm.to_sql ());

 

        SQLEXEC SE = new SQLEXEC ();

        JSONArray arr = se.exec ( "up6_files", SQL, "F_ID", "");

        retourner arr.size ()> 0;

    }

   

    / **

     * Vérifiez s'il y a un répertoire avec le même nom

     * Nom @param

     * @Param pid

     * @revenir

     * /

    Boolean publique exist_same_folder (String name, String pid)

    {

        SqlWhereMerge nouveau montant de SqlWhereMerge = ();

        swm.equal ( "f_nameLoc", name.trim ());

        swm.equal ( "f_deleted", 0);

        swm.equal ( "LTRIM (f_pid)", pid.trim ());

        Chaîne où = swm.to_sql ();

 

        Chaîne sql = String.format ( "(sélectionner F_ID de up6_files où% de) syndicat (choisir F_ID de up6_folders où% s)", où, où);

 

        SQLEXEC SE = new SQLEXEC ();

        JSONArray fid = se.exec ( "up6_files", SQL, "F_ID", "");

        fid.size de retour ()> 0;     

    }

   

    publique booléenne rename_file_check (String newName, String pid)

    {

        SQLEXEC SE = new SQLEXEC ();           

        JSONArray res = se.select ( "up6_files"

            , "F_ID"

            , Nouveau SqlParam [] {

                nouvelle SqlParam ( "f_nameLoc", newName)

                , Nouvelle SqlParam ( "f_pid", pid)

            }, "");

        res.size de retour ()> 0;

    }

   

    publique booléenne rename_folder_check (String newName, String pid)

    {

        SQLEXEC SE = new SQLEXEC ();

        JSONArray res = se.select ( "up6_folders"

            , "F_ID"

            , Nouveau SqlParam [] {

                nouvelle SqlParam ( "f_nameLoc", newName)

                , Nouvelle SqlParam ( "f_pid", pid)

            }, "");

        res.size de retour ()> 0;

    }

 

    rename_file public void (String name, String id) {

        SQLEXEC SE = new SQLEXEC ();

        se.update ( "up6_files"

            , Nouveau SqlParam [] {new SqlParam ( "f_nameLoc", nom)}

            , Nouveau SqlParam [] {new SqlParam ( "F_ID", id)});

    }

   

    rename_folder public void (String name, id String, String pid) {

        SQLEXEC SE = new SQLEXEC ();

        se.update ( "up6_folders"

            , Nouveau SqlParam [] {new SqlParam ( "f_nameLoc", nom)}

            , Nouveau SqlParam [] {new SqlParam ( "F_ID", id)});

    }

}

 

1. webuploader.js probablement d'environ 4880 lignes de code, ce qui suit composant d'entrée généré dynamiquement (entrée peut être recherche directe), augmenter les propriétés webkitdirectory.

fonction FileUploader (fileLoc, mgr)

{

    var _Cette = this;

    this.id = fileLoc.id;

    this.ui = {msg: null, processus: null, pour cent: null, BTN: {del: null, annuler: null, après: null, arrêt: null}, div: null};

    this.isFolder = false; // pas un dossier

    this.app = mgr.app;

    this.Manager = mgr; // gestionnaire de téléchargement pointeur

    this.event = mgr.event;

    this.Config = mgr.Config;

    this.fields = jQuery.extend ({}, mgr.Config.Fields, fileLoc.fields); // pour chacun des champs objet portant une nappe de la présente

    this.State = this.Config.state.None;

    this.uid = this.fields.uid;

    this.fileSvr = {

          pid: ""

        , Id: ""

        , PidRoot: ""

        , F_fdTask: false

        , F_fdChild: false

        , Uid: 0

        , NameLoc: ""

        , NameSvr: ""

        , PathLoc: ""

        , PathSvr: ""

        , PathRel: ""

        , Md5: ""

        , LenLoc: "0"

        , SizeLoc: ""

        , FilePos: "0"

        , LenSvr: "0"

        , PerSvr: "0%"

        , Complète: false

        , Supprimé: false

    } // JSON obj, informations sur le serveur de fichiers

    this.fileSvr = jQuery.extend (this.fileSvr, fileLoc);

2. Vous pouvez obtenir le chemin

     this.open_files = function (json)

     {

         for (var i = 0, l = json.files.length; i <l; i ++)

        {

             this.addFileLoc (json.files [i]);

         }

         setTimeout (function () {_this.PostFirst ();}, 500);

     };

     this.open_folders = function (json)

    {

        for (var i = 0, l = json.folders.length; i <l; i ++) {

            this.addFolderLoc (json.folders [i]);

        }

         setTimeout (function () {_this.PostFirst ();}, 500);

     };

     this.paste_files = function (json)

     {

         for (var i = 0, l = json.files.length; i <l; i ++)

         {

             this.addFileLoc (json.files [i]);

         }

     };

 

 

La plupart de la logique de code back-end est le même, prend actuellement en charge MySQL, Oracle, SQL. Avant d' utiliser la nécessité de configurer la base de données, vous pouvez me référer à écrire cet article: http://blog.ncmem.com/wordpress/2019/08/07/java télécharger et télécharger des fichiers volumineux /

 

Je suppose que tu aimes

Origine www.cnblogs.com/songsu/p/12553671.html
conseillé
Classement