README | 2 ++ src/uploader/main.go | 20 +++++++++++++++++--- diff --git a/README b/README index 823492a49f8895b01a55c1ec6d3b0b1b2b8fad4b..5d674a948daaca55439908757fb05ecb3b281f88 100644 --- a/README +++ b/README @@ -6,6 +6,8 @@ You can upload files with curl: curl -F fileupload=@somedata.tar.gpg http://localhost:8086/upload/ + curl -F fileupload=@somedata.tar.gpg -F comment="optional comment" http://localhost:8086/upload/ + You can verify integrity locally: b2sum -a blake2b somedata.tar.gpg diff --git a/src/uploader/main.go b/src/uploader/main.go index e2154cdc57df52e83648cc9a4fb5cbca0dabe083..c3efd614da06491b530624e2a3dc29456ca7a14d 100644 --- a/src/uploader/main.go +++ b/src/uploader/main.go @@ -23,15 +23,19 @@ "golang.org/x/net/netutil" ) const ( - WriteBufSize = 1 << 20 - FileFieldName = "fileupload" + WriteBufSize = 1 << 20 + FileFieldName = "fileupload" + CommentFieldName = "comment" ) var ( Index = template.Must(template.New("index").Parse(` Upload
- +
+ +
+
`)) ) @@ -88,6 +92,16 @@ return } fmt.Fprintf(w, "Timestamp: %s\nBytes: %d\nBLAKE2b: %s\n", fn, n, sum) log.Println(r.RemoteAddr, fn, p.FileName(), n, sum) + p, err = mr.NextPart() + if err != nil || p.FormName() != CommentFieldName { + return + } + comment, err := ioutil.ReadAll(p) + if err != nil || len(comment) == 0 { + return + } + ioutil.WriteFile(fn+".txt", comment, os.FileMode(0600)) + go notify(fn, n, string(comment)) } func main() {