multipart

package
v0.0.0-...-024ac7e Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 3, 2026 License: ISC Imports: 7 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Streamer

type Streamer struct {
	// contains filtered or unexported fields
}

Streamer is an implementation of a multipart.Writer which allows you to read directly from it

func New

func New() *Streamer

New creates a new Multipart streamer

func (*Streamer) Close

func (s *Streamer) Close() error

Close check every part that may be an io.ReadCloser this isn't necessary if the ReadClosers are manually closed after the request This function itself makes the Streamer an io.Closer

func (*Streamer) ContentType

func (s *Streamer) ContentType() string

ContentType returns the request's content type

func (*Streamer) CreateFormField

func (s *Streamer) CreateFormField(fieldname string, r io.Reader, length int64) error

CreateFormField calls CreatePart with a header using the given field name.

func (*Streamer) CreateFormFile

func (s *Streamer) CreateFormFile(fieldname, filename string, r io.Reader, length int64) error

CreateFormFile is a convenience wrapper around CreatePart. It creates a new form-data header with the provided field name and file name.

func (*Streamer) CreatePart

func (s *Streamer) CreatePart(h textproto.MIMEHeader, r io.Reader, length int64) error

CreatePart functions the same as multipart's CreatePart, but takes a reader instead of returning a writer.

func (*Streamer) Finalize

func (s *Streamer) Finalize() error

Finalize is called when the reader is attempted to be read from, and it does not have an underlying reader to use. It will close the multipart writer, flushing the final part, and append all readers together making us a reader that is able to simply append all the parts as one stream.

func (*Streamer) Len

func (s *Streamer) Len() int64

Len should only be called after Finalize, which calculates the final length

func (*Streamer) LenString

func (s *Streamer) LenString() string

LenString is Len, but returned as a string for ease of use in headers

func (*Streamer) Read

func (s *Streamer) Read(buf []byte) (int, error)

Read implements an io.Reader that can be used to read from this multipart streamer This finalizes the request (with mw.Close) and prepares a reader for reading if it is not ready.

func (*Streamer) WriteField

func (s *Streamer) WriteField(fieldname, value string) error

WriteField calls CreateFormField and then writes the given value.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL