bkmultipart

package
v4.1.0 Latest Latest
Warning

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

Go to latest
Published: Nov 7, 2024 License: BSD-2-Clause Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Streamer

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

A wrapper around the complexities of streaming a multipart file and fields to an http endpoint that infuriatingly requires a Content-Length Stolen/adapted from the multipart streamer in https://github.com/buildkite/agentv/v3/internal/artifact, which itself was derived from https://github.com/technoweenie/multipartstreamer

func NewStreamer

func NewStreamer() *Streamer

NewStreamer initializes a new Streamer.

func (*Streamer) Len

func (s *Streamer) Len() int64

Len calculates the byte size of the multipart content.

func (*Streamer) Reader

func (s *Streamer) Reader() io.Reader

func (*Streamer) WriteField

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

WriteField writes a form field to the multipart.Writer.

func (*Streamer) WriteFields

func (s *Streamer) WriteFields(fields map[string]string) error

func (*Streamer) WriteFile

func (s *Streamer) WriteFile(key string, file *os.File, displayedFilename string) error

WriteFile writes the multi-part preamble which will be followed by file data This can only be called once and must be the last thing written to the streamer

Jump to

Keyboard shortcuts

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