LinuxCommandLibrary

http-server-upload

Serve files via simple HTTP server, upload enabled

TLDR

Start an HTTP server on the default port to upload files to the current directory

$ http-server-upload
copy

Start an HTTP server with the specified maximum allowed file size for uploads in MiB (defaults to 200 MiB)
$ MAX_FILE_SIZE=[size_in_megabytes] http-server-upload
copy

Start an HTTP server on a specific port to upload files to the current directory
$ PORT=[port] http-server-upload
copy

Start an HTTP server, storing the uploaded files in a specific directory
$ UPLOAD_DIR=[path/to/directory] http-server-upload
copy

Start an HTTP server using a specific directory to temporarily store files during the upload process
$ UPLOAD_TMP_DIR=[path/to/directory] http-server-upload
copy

Start an HTTP server accepting uploads with a specific token field in the HTTP post
$ TOKEN=[secret] http-server-upload
copy

SYNOPSIS

http-server-upload [options]

PARAMETERS

-p
    Specifies the port number to listen on. Defaults to 8080.

-d
    Specifies the directory to serve files from and save uploads to. Defaults to the current directory.

-i
    Specifies the network interface to listen on. Defaults to all interfaces.

-s
    Enables silent mode, suppressing console output.

-h, --help
    Displays help information.

--version
    Displays the version number.

DESCRIPTION

The `http-server-upload` command is a Node.js package that provides a straightforward way to set up a basic HTTP server capable of handling file uploads. It's incredibly useful for quickly creating a local server to receive files from other applications or devices. It doesn't require extensive configuration and offers a minimal interface. Typically used for testing purposes or in situations where a simple file upload endpoint is needed without the complexity of a full-fledged web server framework. The server runs in the current directory by default, serving files from and saving uploads to it. Note that security considerations are paramount when using this in production; `http-server-upload` is not designed for secure or high-traffic environments.

CAVEATS

Security Warning: This tool is not designed for production use. It lacks security features and should only be used in trusted environments or for development/testing purposes. Do not expose this server to the public internet without proper security measures. File uploads are saved to the specified directory without any sanitization, which can lead to security vulnerabilities. Consider using more robust and secure solutions for production deployments.
Uploads can overwrite existing files.

INSTALLATION

The `http-server-upload` command can be installed globally using npm: `npm install -g http-server-upload`. This makes the command available from anywhere in your terminal.

EXAMPLE USAGE

To start a server on port 9000 serving files from the `public` directory, use the command: `http-server-upload -p 9000 -d public`. Uploaded files will be saved to the `public` directory as well.

DEPENDENCIES

This tool relies on Node.js and npm (Node Package Manager) to be installed on your system. Ensure you have a compatible version of Node.js installed before attempting to install and use `http-server-upload`.

HISTORY

The `http-server-upload` package is a relatively modern creation, arising from the need for simple, lightweight file upload servers during development and testing workflows. It's typically implemented using Node.js and distributed through npm. Its usage has grown alongside the increasing adoption of Node.js in web development.

SEE ALSO

python3 -m http.server(1), nginx(8), apache2(8)

Copied to clipboard