Documentation ¶
Index ¶
- Constants
- Variables
- func MIMEParseMediaType(v string) (string, map[string]string, error)
- func MIMETypeByExtension(ext string) string
- type File
- type FileHeader
- type Form
- type MultipartReader
- type MultipartWriter
- func (w *MultipartWriter) Boundary() string
- func (w *MultipartWriter) Close() error
- func (w *MultipartWriter) CreateFormField(fieldname string) (io.Writer, error)
- func (w *MultipartWriter) CreateFormFile(fieldname, filename string) (io.Writer, error)
- func (w *MultipartWriter) CreatePart(header Header) (io.Writer, error)
- func (w *MultipartWriter) FormDataContentType() string
- func (w *MultipartWriter) SetBoundary(boundary string) error
- func (w *MultipartWriter) WriteField(fieldname, value string) error
- type QuotedReader
- type SinglePart
- type WordEncoder
Constants ¶
const (
ContentDisposition = "Content-Disposition"
)
Variables ¶
var ( // ErrMessageTooLarge is returned by ReadForm if the message form // data is too large to be processed. ErrMessageTooLarge = errors.New("multipart: message too large") )
Functions ¶
func MIMETypeByExtension ¶
Types ¶
type File ¶
File is an interface to access the file part of a multipart message. Its contents may be either stored in memory or on disk. If stored on disk, the File's underlying concrete type will be an *os.File.
type FileHeader ¶
type FileHeader struct { Filename string Header Header Size int64 // contains filtered or unexported fields }
A FileHeader describes a file part of a multipart request.
func (*FileHeader) Open ¶
func (fh *FileHeader) Open() (File, error)
Open opens and returns the FileHeader's associated File.
type Form ¶
type Form struct { Value map[string][]string File map[string][]*FileHeader }
Form is a parsed multipart form. Its File parts are stored either in memory or on disk, and are accessible via the *FileHeader's Open method. Its Value parts are stored as strings. Both are keyed by field name.
type MultipartReader ¶
type MultipartReader struct {
// contains filtered or unexported fields
}
Reader is an iterator over parts in a MIME multipart body. Reader's underlying parser consumes its input as needed. Seeking isn't supported.
func NewMultipartReader ¶
func NewMultipartReader(r io.Reader, boundary string) *MultipartReader
NewReader creates a new multipart Reader reading from r using the given MIME boundary.
The boundary is usually obtained from the "boundary" parameter of the message's "Content-Type" header. Use ParseMediaType to parse such headers.
func (*MultipartReader) IsBoundaryDelimiterLine ¶
func (r *MultipartReader) IsBoundaryDelimiterLine(line []byte) (ret bool)
func (*MultipartReader) NextPart ¶
func (r *MultipartReader) NextPart() (*SinglePart, error)
NextPart returns the next part in the multipart or an error. When there are no more parts, the error io.EOF is returned.
func (*MultipartReader) ReadForm ¶
func (r *MultipartReader) ReadForm(maxMemory int64) (*Form, error)
ReadForm parses an entire multipart message whose parts have a Content-Disposition of "form-data". It stores up to maxMemory bytes + 10MB (reserved for non-file parts) in memory. File parts which can't be stored in memory will be stored on disk in temporary files. It returns ErrMessageTooLarge if all non-file parts can't be stored in memory.
type MultipartWriter ¶
type MultipartWriter struct {
// contains filtered or unexported fields
}
A Writer generates multipart messages.
func NewMultipartWriter ¶
func NewMultipartWriter(w io.Writer) *MultipartWriter
NewWriter returns a new multipart Writer with a random boundary, writing to w.
func (*MultipartWriter) Boundary ¶
func (w *MultipartWriter) Boundary() string
Boundary returns the Writer's boundary.
func (*MultipartWriter) Close ¶
func (w *MultipartWriter) Close() error
Close finishes the multipart message and writes the trailing boundary end line to the output.
func (*MultipartWriter) CreateFormField ¶
func (w *MultipartWriter) CreateFormField(fieldname string) (io.Writer, error)
CreateFormField calls CreatePart with a header using the given field name.
func (*MultipartWriter) CreateFormFile ¶
func (w *MultipartWriter) CreateFormFile(fieldname, filename string) (io.Writer, error)
CreateFormFile is a convenience wrapper around CreatePart. It creates a new form-data header with the provided field name and file name.
func (*MultipartWriter) CreatePart ¶
func (w *MultipartWriter) CreatePart(header Header) (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 (*MultipartWriter) FormDataContentType ¶
func (w *MultipartWriter) FormDataContentType() string
FormDataContentType returns the Content-Type for an HTTP multipart/form-data with this Writer's Boundary.
func (*MultipartWriter) SetBoundary ¶
func (w *MultipartWriter) 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 (*MultipartWriter) WriteField ¶
func (w *MultipartWriter) WriteField(fieldname, value string) error
WriteField calls CreateFormField and then writes the given value.
type QuotedReader ¶
type QuotedReader struct {
// contains filtered or unexported fields
}
QuotedReader is a quoted-printable decoder.
func NewQuotedReader ¶
func NewQuotedReader(r io.Reader) *QuotedReader
NewReader returns a quoted-printable reader, decoding from r.
type SinglePart ¶
type SinglePart struct { // The headers of the body, if any, with the keys canonicalized // in the same fashion that the Go http.Request headers are. // For example, "foo-bar" changes case to "Foo-Bar" // // As a special case, if the "Content-Transfer-Encoding" header // has a value of "quoted-printable", that header is instead // hidden from this map and the body is transparently decoded // during Read calls. Header Header // contains filtered or unexported fields }
A Part represents a single part in a multipart body.
func (*SinglePart) Close ¶
func (p *SinglePart) Close() error
func (*SinglePart) FileName ¶
func (p *SinglePart) FileName() string
FileName returns the filename parameter of the Part's Content-Disposition header.
func (*SinglePart) FormName ¶
func (p *SinglePart) FormName() string
FormName returns the name parameter if part has a Content-Disposition of type "form-data". Otherwise it returns the empty string.