Documentation
¶
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 New ¶
func New() (m *MultipartStreamer)
Helps you build multipart for large files without reading the file until the multipart reader is being read. It does this by creating the file field last and using an io.MultiReader to combine the multipart.Reader with the file handle. The trailing boundary is manually added in another buffer.
func (*MultipartStreamer) Boundary ¶
func (m *MultipartStreamer) Boundary() string
func (*MultipartStreamer) GetReader ¶
func (m *MultipartStreamer) GetReader() io.ReadCloser
Gets an io.ReadCloser for passing to an http.Request.
func (*MultipartStreamer) Len ¶
func (m *MultipartStreamer) Len() int64
Calculates the byte size of the multipart content.
func (*MultipartStreamer) SetupRequest ¶
func (m *MultipartStreamer) SetupRequest(req *http.Request)
Sets up the http.Request body, and some crucial HTTP headers.
func (*MultipartStreamer) WriteFields ¶
func (m *MultipartStreamer) WriteFields(fields map[string]string) error
Writes form fields to the multipart.Writer.
func (*MultipartStreamer) WriteFile ¶
func (m *MultipartStreamer) WriteFile(key, filename string) error
Shortcut for adding a local file as an io.Reader.
key - The name of the field for the file data.
filename - The full path of the file to upload. Only the basename of the
full path is sent to the multipart.Reader.
func (*MultipartStreamer) WriteReader ¶
func (m *MultipartStreamer) WriteReader(key, filename string, size int64, reader io.Reader) (err error)
Adds a reader to of some file content for the multipart.Reader. This reader is not accessed until the multipart.Reader is copied to some output writer.