• Home
  • History
  • Annotate
Name Date Size #Lines LOC

..03-May-2022-

examples/H20-Oct-2013-6048

script/H20-Oct-2013-22

LICENSEH A D20-Oct-20131 KiB84

README.mdH A D20-Oct-2013996 4832

multipartstreamer.goH A D20-Oct-20132.6 KiB10270

multipartstreamer_test.goH A D20-Oct-20132.6 KiB12598

README.md

1# multipartstreamer
2
3Package multipartstreamer helps you encode large files in MIME multipart format
4without reading the entire content into memory.  It uses io.MultiReader to
5combine an inner multipart.Reader with a file handle.
6
7```go
8package main
9
10import (
11  "github.com/technoweenie/multipartstreamer.go"
12  "net/http"
13)
14
15func main() {
16  ms := multipartstreamer.New()
17
18  ms.WriteFields(map[string]string{
19    "key":			"some-key",
20    "AWSAccessKeyId":	"ABCDEF",
21    "acl":			"some-acl",
22  })
23
24  // Add any io.Reader to the multipart.Reader.
25  ms.WriteReader("file", "filename", some_ioReader, size)
26
27  // Shortcut for adding local file.
28  ms.WriteFile("file", "path/to/file")
29
30  req, _ := http.NewRequest("POST", "someurl", nil)
31  ms.SetupRequest(req)
32
33  res, _ := http.DefaultClient.Do(req)
34}
35```
36
37One limitation: You can only write a single file.
38
39## TODO
40
41* Multiple files?
42
43## Credits
44
45Heavily inspired by James
46
47https://groups.google.com/forum/?fromgroups=#!topic/golang-nuts/Zjg5l4nKcQ0
48