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
)
const (
- WriteBufSize = 1 << 20
- FileFieldName = "fileupload"
+ WriteBufSize = 1 << 20
+ FileFieldName = "fileupload"
+ CommentFieldName = "comment"
)
var (
Index = template.Must(template.New("index").Parse(`<html>
<head><title>Upload</title></head><body>
<form enctype="multipart/form-data" action="/upload/" method="post">
-<input type="file" name="{{.}}" /><input type="submit" />
+<input type="file" name="{{.}}" /><br/>
+<label for="comment">Optional comment:</label>
+<textarea name="comment" cols="80" rows="25" name="comment"></textarea><br/>
+<input type="submit" />
</form></body></html>`))
)
}
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() {