Documentation ¶
Overview ¶
Package multipartstreamer helps you encode large files in MIME multipart format without reading the entire content into memory. It uses io.MultiReader to combine an inner multipart.Reader with a file handle.
Index ¶
- type MultipartStreamer
- func (m *MultipartStreamer) Boundary() string
- func (m *MultipartStreamer) GetReader() io.ReadCloser
- func (m *MultipartStreamer) Len() int64
- func (m *MultipartStreamer) SetupRequest(req *http.Request)
- func (m *MultipartStreamer) WriteFields(fields map[string]string) error
- func (m *MultipartStreamer) WriteFile(key, filename string) error
- func (m *MultipartStreamer) WriteReader(key, filename string, size int64, reader io.Reader) (err error)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type MultipartStreamer ¶
type MultipartStreamer struct { ContentType string // contains filtered or unexported fields }
func (*MultipartStreamer) Boundary ¶
func (m *MultipartStreamer) Boundary() string
func (*MultipartStreamer) GetReader ¶
func (m *MultipartStreamer) GetReader() io.ReadCloser
GetReader gets an io.ReadCloser for passing to an http.Request.
func (*MultipartStreamer) Len ¶
func (m *MultipartStreamer) Len() int64
Len calculates the byte size of the multipart content.
func (*MultipartStreamer) SetupRequest ¶
func (m *MultipartStreamer) SetupRequest(req *http.Request)
SetupRequest sets up the http.Request body, and some crucial HTTP headers.
func (*MultipartStreamer) WriteFields ¶
func (m *MultipartStreamer) WriteFields(fields map[string]string) error
WriteFields writes multiple form fields to the multipart.Writer.
func (*MultipartStreamer) WriteFile ¶
func (m *MultipartStreamer) WriteFile(key, filename string) error
WriteFile is a shortcut for adding a local file as an io.Reader.
func (*MultipartStreamer) WriteReader ¶
func (m *MultipartStreamer) WriteReader(key, filename string, size int64, reader io.Reader) (err error)
WriteReader adds an io.Reader to get the content of a file. The reader is not accessed until the multipart.Reader is copied to some output writer.