Simplest HTTP form file uploader.
It just saves uploaded file from HTML form to the new file on the disk.
-Also it calculates BLAKE2b-512 checksum, replying with it in the answer.
+Also it calculates BLAKE3-256 checksum, replying with it in the answer.
You can upload files with curl:
and verify integrity locally:
- b2sum somedata.tar.gpg
+ b3sum 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
go 1.17
require (
- go.cypherpunks.ru/recfile v0.5.1
+ go.cypherpunks.ru/recfile v0.7.0
go.cypherpunks.ru/tai64n/v2 v2.0.0
- golang.org/x/crypto v0.1.0
- golang.org/x/net v0.2.0
+ golang.org/x/net v0.9.0
+ lukechampine.com/blake3 v1.1.7
)
-require golang.org/x/sys v0.2.0 // indirect
+require github.com/klauspost/cpuid/v2 v2.0.9 // indirect
-go.cypherpunks.ru/recfile v0.5.1 h1:Sk9Og/7aybvg4PrZdhyFSeEdS6wvcisvd+1oGf8uFyU=
-go.cypherpunks.ru/recfile v0.5.1/go.mod h1:sR+KajB+vzofL3SFVFwKt3Fke0FaCcN1g3YPNAhU3qI=
+github.com/klauspost/cpuid/v2 v2.0.9 h1:lgaqFMSdTdQYdZ04uHyN2d/eKdOMyi2YLSvlQIBFYa4=
+github.com/klauspost/cpuid/v2 v2.0.9/go.mod h1:FInQzS24/EEf25PyTYn52gqo7WaD8xa0213Md/qVLRg=
+go.cypherpunks.ru/recfile v0.7.0 h1:0R1UnDGKccp7JnC66msslJMlSY02jHx/XkW+ISl0GuY=
+go.cypherpunks.ru/recfile v0.7.0/go.mod h1:sR+KajB+vzofL3SFVFwKt3Fke0FaCcN1g3YPNAhU3qI=
go.cypherpunks.ru/tai64n/v2 v2.0.0 h1:AlohA1/zRqInhIGK7CVnn7tC5/vt1TaOAEyBgeu5Ruo=
go.cypherpunks.ru/tai64n/v2 v2.0.0/go.mod h1:9eeXyzoNO/8grf+bw+T1HXRCRjHVXjUsvnIyaUkjS5I=
-golang.org/x/crypto v0.1.0 h1:MDRAIl0xIo9Io2xV565hzXHw3zVseKrJKodhohM5CjU=
-golang.org/x/crypto v0.1.0/go.mod h1:RecgLatLF4+eUMCP1PoPZQb+cVrJcOPbHkTkbkB9sbw=
-golang.org/x/net v0.2.0 h1:sZfSu1wtKLGlWI4ZZayP0ck9Y73K1ynO6gqzTdBVdPU=
-golang.org/x/net v0.2.0/go.mod h1:KqCZLdyyvdV855qA2rE3GC2aiw5xGR5TEjj8smXukLY=
-golang.org/x/sys v0.2.0 h1:ljd4t30dBnAvMZaQCevtY0xLLD0A+bRZXbgLMLU1F/A=
-golang.org/x/sys v0.2.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
+golang.org/x/net v0.9.0 h1:aWJ/m6xSmxWBx+V0XRHTlrYrPG56jKsLdTFmsSsCzOM=
+golang.org/x/net v0.9.0/go.mod h1:d48xBJpPfHeWQsugry2m+kC02ZBRGRgulfHnEXEuWns=
+lukechampine.com/blake3 v1.1.7 h1:GgRMhmdsuK8+ii6UZFDL8Nb+VyMwadAgcJyfYHxG6n0=
+lukechampine.com/blake3 v1.1.7/go.mod h1:tkKEOtDkNtklkXtLNEOGNq5tcV90tJiA1vAA12R78LA=
"go.cypherpunks.ru/recfile"
"go.cypherpunks.ru/tai64n/v2"
- "golang.org/x/crypto/blake2b"
"golang.org/x/net/netutil"
+ "lukechampine.com/blake3"
)
const (
Example command line usage:
<pre>
$ curl -F file=@somedata.tar.gpg [-F comment="optional comment"] http://.../upload/
-$ b2sum somedata.tar.gpg # to verify BLAKE2b-512 checksum
+$ b3sum somedata.tar.gpg # to verify BLAKE3-256 checksum
</pre>
<form enctype="multipart/form-data" action="/upload/" method="post">
<label for="file">File to upload:</label><br/>
log.Println(r.RemoteAddr, "non file form field")
return
}
- h, err := blake2b.New512(nil)
- if err != nil {
- panic(err)
- }
t := time.Now()
ts := new(tai64n.TAI64N)
ts.FromTime(t)
return
}
fdBuf := bufio.NewWriterSize(fd, WriteBufSize)
+ h := blake3.New(32, nil)
mw := io.MultiWriter(fdBuf, h)
n, err := io.Copy(mw, p)
if err != nil {