Giter Site home page Giter Site logo

http-server-upload's Introduction

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

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 [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.

Attention: Already existing files will be overwritten on upload.

Environment variables

Variable Description Default
PORT The port to use. 8080
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 Temp directory for the file upload. The upload directory.
MAX_FILE_SIZE The maximum allowed file size for uploads in Megabyte. 200
TOKEN An optional token which must be provided on upload. Nothing
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-_/]*$/

Example:

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

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

License

MIT license

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

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.