0.1.6 • Published 6 months ago

nodejs-form-parse v0.1.6

Weekly downloads
-
License
ISC
Repository
-
Last release
6 months ago
var { form_parse, form_parse_multi, remove_images, remove_files } = require('nodejs-form-parse');

function test(req, res){

    var options = { 
        multiples : true, 
        uploadDir : "./public/",
        resize : {
            width : 50, // or "auto"
            height : 50 // or "auto"
        }
    };

    form_parse(req, options)
    .then(body => {

        // if multiple == true -> body.images [ "", "" ]
        // if multiple == false -> body.image ""

        res.json({body});

    })
    .catch(err => {

        // err
        res.json({err});

    });

    remove_images({ path : "./public/", image }); // or images array [ "img.png" ]
    remove_files({ path : "./public/", file }); // or files array [ "file.txt" ]

}

function test_multi(req, res){

    var options = { 
        multiples : true, // default true
        uploadDir : "./public/", 
        config : {
            poster : {
                uploadDir : "./public/poster/", // not required
                resize : { 
                    width : 50, // or "auto"
                    height : 60 // or "auto"
                }
            },
            galery : {
                uploadDir : "./public/galery/",
                resize : {
                    width : "auto", 
                    height : 70 // or "auto"
                }
            }
        }
    };
 
    form_parse_multi(req, options)
    .then(body => {

        // body.poster []
        // body.galery []

        res.json({body});
 
    })
    .catch(err => {
        res.json({err});
    });

}

module.exports = { test, test_multi }
0.1.6

6 months ago

0.1.4

4 years ago

0.1.3

4 years ago

0.1.5

4 years ago

0.1.2

4 years ago

0.1.1

4 years ago

0.1.0

4 years ago

0.0.9

4 years ago

0.0.8

4 years ago

0.0.7

4 years ago

0.0.6

4 years ago

0.0.5

4 years ago

0.0.4

4 years ago

0.0.3

4 years ago

0.0.2

4 years ago

0.0.1

4 years ago