File Transfer Tool in Node.js
I am often faced with the issue of transferring files from one server to another - getting your PDF file onto an Android phone, share your latest model data with a co-worker or testing an IoT devices FTP upload to your server. The candy store at the node modules manager offers two tools that allow you to do that with a simple one-liner on your console or terminal - on LINUX, Windows or macOS.
httpster
httpster is a simple http server that gives you access to a directory on your server through the HTTP protocol.
Installation
Installation is done via npm, which is installed along with NodeJS on most platforms.
npm -g install httpster
Then from any directory where you want to have an http service running, just run
httpster
That will start up a web server on port 3333 and let you serve up any static content you wish. If you want to change the port or directory that the server runs from pass in the -p or -d options
httpster -p 8080 -d /home/somedir/public_html
HTML5 Pushstates
If you want to run a local site that supports HTML5 Pushstates (aka being able to refresh the page), pass in the option -s
or --pushstate
. This will map all 4oh4's to the index.html you specified as root directory.
Basic Authentication
Since you can use httpster to deploy to PaaS providers like heroku you can now secure those deployments with basic authentication. The -b
or --basic_auth
options will read the HTTPSTER_AUTH_USER and HTTPSTER_AUTH_PASS variables from your environment for authentication.
httpster -b
or
httpster --basic_auth
If testing this locally you can also use a .env file in the directory you will run httpster from.
HTTPSTER_AUTH_USER=desired_username
HTTPSTER_AUTH_PASS=desired_password
Then use the -e
or --env
option to specify to load the environmental variables:
httpster --env --basic_auth
Symbolic Links
For security purposes symbolic links have been disabled in the default usage. If you need to serve content through symbolic links you can add the following flag when launching httpster.
httpster -l
or
httpster --symlink
ftp-srv
ftp-srv is a modern and extensible FTP server designed to be simple yet configurable.
Installation
Install the package through npm:
npm install -g ftp-srv
Start your FTP Server
ftp-srv comes with a builtin CLI:
$ ftp-srv [url] [options]
To spin up your FTP service on a server with the local IP address 192.168.2.111
in the root directory /opt/ftp-srv/uploads
(make sure it exists and the user that executes the FTP service is allowed to write to it!) run the following command:
ftp-srv ftp://192.168.2.111:9876 --root /opt/ftp-srv/uploads --username ftpuser --password password
Usage
You can now use a tool like Filezilla to test your service:
Or with your INSTAR IP camera: