npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

http-server-upload

v3.0.0

Published

A Simple zero-configuration command-line http server for uploading files

Downloads

98

Readme

http-server-upload

NPM version Downloads

NPM

This is a simple zero-configuration command-line http server which provides a lightweight interface to upload files.

By default files are uploaded to the current working directory.

Optionally a token may be used to protect against unauthorized uploads.

Installation

Version 3 of http-server-upload requires Node.js 14.18 or higher.

npm install --global http-server-upload

This will install http-server-upload globally so that it may be run from the command line.

Usage

http-server-upload [arguments] [uploadRootPath]

[uploadRootPath] defaults to the current working directory (./).

Other options can be set using environment variables.

When the server is running you can visit http://localhost:8080/ to get the upload form.

If the desired port is already in use, the port will be increased automatically until the next free port is found. This can be disabled, see below.

Attention: Already existing files will be overwritten on upload.

Arguments and environment variables

The optional configuration is done by command line arguments or environment variables.
If both are used, the arguments have higher priority and the value from the corresponding environment variable will be ignored.

| Argument | Variable | Description | Default | |---|---|---|---| | --port | PORT | The port to use. | 8080 | | --upload-dir | UPLOAD_DIR | The directory where the files should be uploaded to. This overrides the uploadRootPath argument. | uploadRootPath argument or the current working directory | | --upload-tmp-dir | UPLOAD_TMP_DIR | Temp directory for the file upload. | The upload directory. | | --max-file-size | MAX_FILE_SIZE | The maximum allowed file size for uploads in Megabyte. | 200 | | --token | TOKEN | An optional token which must be provided on upload. | Nothing | | --path-regexp | PATH_REGEXP | A regular expression to verify a given upload path. This should be set with care, because it may allow write access to outside the upload directory. | /^[a-zA-Z0-9-_/]*$/ | | --disable-auto-port | DISABLE_AUTO_PORT | Disable automatic port increase if the port is nor available. | Not set. | | --enable-folder-creation | ENABLE_FOLDER_CREATION | Enable automatic folder creation when uploading file to non-existent folder. | Not set. | | --index-file | INDEX_FILE | Use a custom html file as index instead of the default internal index. If used, the form fields need to have the same names as in the original index. | Not set. | | --help, -h | | Show some help text | |

Examples:

PORT=9000 UPLOAD_DIR=~/uploads/ UPLOAD_TMP_DIR=/tmp/ TOKEN=my-super-secret-token http-server-upload

http-server-upload --port=9000 --upload-dir="c:\users\peter\Path With Whitespaces\"

PORT=9000 http-server-upload --disable-auto-port --enable-folder-creation ./

Uploads from the command line

If the http-server-upload is running, you may also upload files from the command line using curl:

curl -F "[email protected]" http://localhost:8080/upload

Advanced example with multiple files, an upload path and a required token:

curl \
  -F "[email protected]" \
  -F "[email protected]" \
  -F "path=my/dir" \
  -F "token=my-super-secret-token" \
  http://localhost:8080/upload

Example for uploading content from a pipe:

cat my-file.dat \
  | curl -F "uploads=@-;filename=my-file.dat;type=application/octet-stream" \
  http://localhost:8080/upload

Notice the required filename and type defintions for uploading piped data.
The type is the mime type of the data to upload.

License

MIT license

Copyright (c) 2019-2023 Peter Müller [email protected] https://crycode.de