All checks were successful
checks / check and test (push) Successful in 53s
|
||
---|---|---|
.gitea/workflows | ||
.gitignore | ||
README.md | ||
go.mod | ||
go.sum | ||
upload.go | ||
upload_test.go |
Some utils for HTTP
Uploader
Uploader is a tool support large files upload with no extra memory and tmp files.
u := NewUploader().
AddFile("file", filepath.Base(p), bytes.NewReader(bs)).
SetParams(map[string][]string{
"name": []string{"myname"},
})
then
rd, err := u.Body()
req, err := http.NewRequest("POST", url, rd)
req.Header.Add("Content-Type", u.ContentType())
If you want to customerize your boundary name,
u := NewUploader().SetBoundary("mytestboundary").
AddFile("file", filepath.Base(p), bytes.NewReader(bs)).
SetParams(map[string][]string{
"name": []string{"myname"},
})