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