contents
            
            
npm install http-file-upload -g
                                
                                
http-file-upload -version
                                
                                
c:/users/<user>/AppData/Roaming/npm/
                                
                                
http-file-upload.cmd -version
                                
                            
npm install http-file-upload
                                
                                
node-x -add
                                
                                
node-x http-file-upload.js -version
                                
                            
npm uninstall http-file-upload -g
                                
                            | -p | -port | <port> | sets the port the server listens on | 
| -d | -dir | 
<dir>
                                                 | sets a directory to put new uploads or where to find files for download, its relative to the serving directory, if the directory does not exist it is created | 
| -cwd | <directory> | sets the current working directory for the script | 
| -https | -http | set whether the server uses https ( default ) or http | |
| -cert | <cert-file> <key-file> | specify a public certificate to use, pem format, the current certificate and key will be replaced and written to the file generate https certificates | 
| -v | -version | prints the current version of the program | |
| -h | -help | command line quick help | 
https://127.0.0.1:3000/download?<filename>
                                
                            
https://127.0.0.1:3000/download-list
{files:["a.txt","b.txt"]}
                                
                            
https://127.0.0.1:3000/upload?<filename>
                                
                            
escape / q / ctrl-c
                                
                                
http-file-upload
                                
                            
http-file-upload -p 4000
                                
                            
var url     = 'https://localhost:3000/download?myfile.js';
var opts    = {rejectUnauthorized:false};
require('https').get(url,opts,async res=>{
  // node >v20
  
      var body    = '';
      for await(data of res)body   += data;
      console.log(body);   
  
  // not using for await ...
  
      var body  = '';
      res.on('data',data=>body+=data);
      res.on('end',()=>console.log(body));
      
});
                                
                            
var url     = 'https://localhost:3000/download?video.mp4';
var opts    = {rejectUnauthorized:false};
require('https').get(url,opts,async res=>{
      var fd    = require('fs').createWriteStream('/tmp/video.mp4');
      res.pipe(fd);
  
});
                                
                            
var url     = 'https://localhost:3000/';
var opts    = {rejectUnauthorized:false};
var https   = require('https');
https.get(`${url}download-list`,opts,async res=>{
      var body    = '';
      res.on('data',data=>body+=data);
      res.on('end',()=>{
      
            var json    = JSON.parse(body);
            json.files.forEach(file=>{
            
                  https.get(`${url}download?${file}`,opts,res=>{
                  
                        var fd    = fs.createWriteStream(file);
                        res.pipe(fd);
                    
                  });
              
            });
            
      });
  
});
                                
                            
var url     = 'https://localhost:3000/upload?my-file.txt';
var body    = require('fs').readFileSync('my-file.txt');
var req     = require('https').request(url,{method:'post',rejectUnauthorized:false},rec);
req.write(body);
req.end();
req.on('error', function(err){
      console.log(err);
});
async function rec(res){
      var body = '';
      res.on('data',data=>body+=data);
      res.on('end',()=>console.log(body));
      
}//rec
                                
                            
var fd      = require('fs').createReadStream('video.mp4');
var url     = 'https://localhost:3000/upload?video.mp4';
var opts    = {method:'post',rejectUnauthorized:false};
var req     = require('https').request(url,opts,rec);
req.on('error',err=>console.log(err));
fd.pipe(req);
async function rec(res){
      var body = '';
      res.on('data',data=>body+=data);
      res.on('end',()=>console.log(body));
      
}//rec
                                
                            
var input         = document.createElement('input');
input.type        = 'file';
input.onchange    = onchange;
input.click();
async function onchange(e){
      var file    = input.files[0];
      var url     = `https://localhost:3000/upload?${file.name}`;
      var res     = await fetch(url,{method:'post',body:file});
      var txt     = await res.text();
      console.log(txt);
      
}//onchange
                                
                            
curl --insecure https://localhost:3000/download?my-file.txt
                                
                            
npx http-file-upload -cwd /work/tmp/
                                
                            
node http-file-upload -cwd /work/tmp/
                                
                            
http-file-upload -cert server-cert.pem private-key.pem
                                
                            
http-file-upload -http
                                
                            
npm install http-file-upload
                                
                                
npx http-file-upload -version
                                
                            
node http-file-upload -version
                                    
                                
http-file-upload/ext/
                                    
should be added to the system path,
                                    
http-file-upload
                                    
                                    
comes with the following shell scripts to launch the process :
                                    
                                
windows ............ http-file-upload/ext/http-file-upload.bat
mac ................ http-file-upload/ext/http-file-upload.sh
linux .............. http-file-upload/ext/http-file-upload.sh