Golang util for HTTP, upload large files with no extra memory and tmp files
Go to file
Lunny Xiao f28da210c9
All checks were successful
checks / check and test (push) Successful in 53s
Fix ci path
2023-04-21 11:36:14 +08:00
.gitea/workflows Fix ci path 2023-04-21 11:36:14 +08:00
.gitignore Init project 2020-08-14 16:12:57 +08:00
go.mod Init project 2020-08-14 16:12:57 +08:00
go.sum Init project 2020-08-14 16:12:57 +08:00
README.md Use actions instead of drone 2023-04-21 11:35:01 +08:00
upload_test.go Fix bug when upload two files 2020-10-28 11:53:36 +08:00
upload.go Add addparam 2020-11-13 13:44:36 +08:00

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"},
        })