multipart

package
v0.4.0 Latest Latest
Warning

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

Go to latest
Published: Apr 17, 2024 License: BSD-3-Clause Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Writer

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

A Writer generates multipart messages.

func NewWriter

func NewWriter(w io.Writer) *Writer

NewWriter returns a new multipart Writer with a random boundary, writing to w.

func (*Writer) Boundary

func (w *Writer) Boundary() string

Boundary returns the Writer's boundary.

func (*Writer) Close

func (w *Writer) Close() error

Close finishes the multipart message and writes the trailing boundary end line to the output.

func (*Writer) CreateFormField

func (w *Writer) CreateFormField(fieldname string) (io.Writer, error)

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

func (*Writer) CreateFormFile

func (w *Writer) CreateFormFile(fieldname, filename, ctype string) (io.Writer, error)

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

func (*Writer) CreatePart

func (w *Writer) CreatePart(header textproto.MIMEHeader) (io.Writer, error)

CreatePart creates a new multipart section with the provided header. The body of the part should be written to the returned Writer. After calling CreatePart, any previous part may no longer be written to.

func (*Writer) FormDataContentType

func (w *Writer) FormDataContentType() string

FormDataContentType returns the Content-Type for an HTTP multipart/form-data with this Writer's Boundary.

func (*Writer) SetBoundary

func (w *Writer) SetBoundary(boundary string) error

SetBoundary overrides the Writer's default randomly-generated boundary separator with an explicit value.

SetBoundary must be called before any parts are created, may only contain certain ASCII characters, and must be non-empty and at most 70 bytes long.

func (*Writer) WriteField

func (w *Writer) WriteField(fieldname, value string) error

WriteField calls Writer.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