-Simplest form file uploader.
+Simplest HTTP form file uploader.
It just saves uploaded file from HTML form to the new file on the disk.
-Also it calculates BLAKE2b checksum, replying with it in the answer.
+Also it calculates BLAKE2b-512 checksum, replying with it in the answer.
You can upload files with curl:
[ -F comment="optional comment" ] \
http://localhost:8086/upload/
-You can verify integrity locally:
+and verify integrity locally:
b2sum -a blake2b somedata.tar.gpg
You can enable mail notification with -notify-to and -notify-from options.
+It is advisable to run it under daemontools-like supervisor
+(http://cr.yp.to/daemontools.html). Example service/uploader provided.
uploader is free software: see the file COPYING for copying conditions.
var (
Index = template.Must(template.New("index").Parse(`<html>
<head><title>Upload</title></head><body>
-<pre>
Example command line usage:
-
- $ curl -F file=@somedata.tar.gpg [-F comment="optional comment"] http://.../upload/
- $ b2sum -a blake2b somedata.tar.gpg # to verify checksum
+<pre>
+$ curl -F file=@somedata.tar.gpg [-F comment="optional comment"] http://.../upload/
+$ b2sum -a blake2b somedata.tar.gpg # to verify checksum
</pre>
<form enctype="multipart/form-data" action="/upload/" method="post">
<label for="file">File to upload:</label><br/>
func main() {
bind := flag.String("bind", "[::]:8086", "Address to bind to")
conns := flag.Int("conns", 2, "Maximal number of connections")
- NotifyFromAddr = flag.String("notify-from", "uploader@example.com", "Address notifications are send to")
- NotifyToAddr = flag.String("notify-to", "", "Address notifications are send from")
+ NotifyFromAddr = flag.String("notify-from", "uploader@example.com", "Address notifications are sent to")
+ NotifyToAddr = flag.String("notify-to", "", "Address notifications are sent from")
flag.Parse()
+ log.SetFlags(log.Lshortfile)
+ log.SetOutput(os.Stdout)
if len(*NotifyFromAddr) == 0 && len(*NotifyToAddr) > 0 {
log.Fatalln("notify-from address can not be empty, if notify-to is set")
}
+++ /dev/null
-#!/bin/sh
-#
-# $FreeBSD$
-#
-# PROVIDE: uploader
-# REQUIRE: DAEMON NETWORKING FILESYSTEMS
-# KEYWORD: shutdown
-#
-# Add these lines to /etc/rc.conf.local or /etc/rc.conf
-# to enable this service:
-#
-# uploader_enable (bool): Set to NO by default.
-# Set it to YES to enable uploader.
-# uploader_chdir (path): Set to /storage/gw/incoming by default.
-# uploader_bind (string): Address:port to bind to
-# Default is "[::]:8086".
-
-. /etc/rc.subr
-
-name=uploader
-rcvar=uploader_enable
-
-load_rc_config $name
-
-: ${uploader_enable:="NO"}
-: ${uploader_chdir="/storage/gw/incoming"}
-: ${uploader_bind="[::]:8086"}
-
-command=/home/stargrave/uploader
-command_args="-bind '$uploader_bind' >> log 2>&1 &"
-command_chdir=$uploader_chdir
-uploader_user=stargrave
-
-run_rc_command "$1"
--- /dev/null
+#!/bin/sh -e
+exec setuidgid uploader multilog t ./main
--- /dev/null
+#!/bin/sh -e
+cd /path/to/incoming
+exec setuidgid uploader /path/to/uploader -bind "[::]:8086" \
+ -notify-from uploader@example.com -notify-to admin@example.com