lib/multi-data.js
function postImage(options, filename, headers, cb) {
    Step(
        function readImage() {
            fs.readFile(filename, this);
        },
        function(err, filecontents) {
            if (err) {
                console.log('Unable to read file', __dirname);
                return;
            }
            postData(null, [{
                type: 'image/jpeg',
                keyname: 'image',
                valuename: 'image.jpg',
                data: filecontents
            }], options, headers, this);
        },
        function(err, response, body) {
            cb && cb(err, response);
            console.log("response code " + response.statusCode, ", body is : ", body);
        }
    );
}
function postImage(options, filename, headers, cb) {
    Step(
        function readImage() {
            fs.readFile(filename, this);
        },
        function(err, filecontents) {
            if (err) {
                console.log('Unable to read file', __dirname);
                return;
            }
            postData(null, [{
                type: 'image/jpeg',
                keyname: 'image',
                valuename: 'image.jpg',
                data: filecontents
            }], options, headers, this);
        },
        function(err, response, body) {
            cb && cb(err, response);
            console.log("response code " + response.statusCode, ", body is : ", body);
        }
    );
}
function postImage ( options , filename , headers , cb ) { Step ( function readImage ( ) { fs . readFile ( filename , this ) ; } , function ( err , filecontents ) { if ( err ) { console . log ( 'Unable to read file' , __dirname ) ; return ; } postData ( null , [ { type : 'image/jpeg' , keyname : 'image' , valuename : 'image.jpg' , data : filecontents } ] , options , headers , this ) ; } , function ( err , response , body ) { cb && cb ( err , response ) ; console . log ( "response code " + response . statusCode , ", body is : " , body ) ; } ) ; }
Sends a post form request via http
- `options` is a set of options
- host
- port
- path
- method
- encoding
- `filename` filename being uploaded
- `headers` headers to be sent with the request
Sends a post form request via http - options is a set of options - host - port - path - method - encoding - filename filename being uploaded - headers headers to be sent with the request