Sign inSign up

crycode/http-server-upload

By crycode

•Updated 3 months ago

A simple command-line http server which provides a lightweight interface to upload files.

Image
0

6.8K

crycode/http-server-upload repository overview

⁠crycode/http-server-upload

GitHub: https://github.com/crycode-de/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 /upload directory in the docker container.

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

⁠Usage

Simple usage example:

docker run --rm -it -p 8080:8080 crycode/http-server-upload

You may also overwrite default options using environment variables (see below for available variables) and use volumes or bind mounts for upload storage:

docker run --rm -it -p 8080:8080 -e TOKEN=foo -e ENABLE_FOLDER_CREATION=1 -v $(pwd):/upload crycode/http-server-upload
⁠Environment variables

The optional configuration is done by environment variables.

VariableDescriptionDefault
PORTThe port to use.8080
UPLOAD_DIRThe directory where the files should be uploaded to. This overrides the uploadRootPath argument.uploadRootPath argument or the current working directory
UPLOAD_TMP_DIRTemp directory for the file upload.The upload directory.
MAX_FILE_SIZEThe maximum allowed file size for uploads in Megabyte.200
TOKENAn optional token which must be provided on upload.Nothing
PATH_REGEXPA 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-_/]*$/
ENABLE_FOLDER_CREATIONEnable automatic folder creation when uploading file to non-existent folder.Not set.
INDEX_FILEUse 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.
⁠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-2024 Peter Müller [email protected]⁠ https://crycode.de⁠

Tag summary

Content type

Image

Digest

sha256:2ad289f79…

Size

77.2 MB

Last updated

3 months ago

docker pull crycode/http-server-upload