multipart

package
v0.1.429 Latest Latest
Warning

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

Go to latest
Published: Jun 25, 2025 License: Apache-2.0 Imports: 13 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

type Client interface {
	NewMultipartBody(ctx context.Context, file []byte, fileName string) (io.Reader, string, error)
	Store(ctx context.Context, r *http.Request, opts StoreOptions) error
}

func NewClient

func NewClient(d Dependencies) (Client, error)

type DefaultTool added in v0.1.11

type DefaultTool struct {
	T *contract.Tool[Client]
}

func NewTool

func NewTool(c Client, opts contract.ToolOptions[Client]) *DefaultTool

func (*DefaultTool) NewMultipartBody added in v0.1.245

func (d *DefaultTool) NewMultipartBody(ctx context.Context, file []byte, fileName string) (io.Reader, string, error)

NewMultipartBody generates a multipart request body and returns the body and content type.

func (*DefaultTool) Store added in v0.1.11

func (d *DefaultTool) Store(ctx context.Context, r *http.Request, opts StoreOptions) error

Store sends a file to a storage service using a multipart request.

type Dependencies added in v0.1.8

type Dependencies struct {
	HR contract.HTTPRequester
	HD contract.HTTPDoer
	HU contract.HTTPUtil
}

type StoreOption

type StoreOption func(*StoreOptions)

func WithBaseURL

func WithBaseURL(x *url.URL) StoreOption

func WithBody

func WithBody(x io.Reader) StoreOption

func WithExpectedStatus

func WithExpectedStatus(x int) StoreOption

func WithFormDataContentType

func WithFormDataContentType(x string) StoreOption

func WithForwardHeaders

func WithForwardHeaders(x ...string) StoreOption

func WithQueryParams

func WithQueryParams(x url.Values) StoreOption

type StoreOptions

type StoreOptions struct {
	BaseURL             *url.URL
	QueryParams         url.Values
	Body                io.Reader
	ForwardHeaders      []string
	FormDataContentType string
	ExpectedStatus      int
}

func ApplyStoreOptions

func ApplyStoreOptions(opts *StoreOptions, modifiers ...StoreOption) StoreOptions

type Tool added in v0.1.245

type Tool interface {
	Client
}

type UploadParams

type UploadParams struct {
	Body                io.Reader
	QueryParams         map[string][]string
	BaseUrl             string
	FormDataContentType string
	ExpectedStatus      int
}

Jump to

Keyboard shortcuts

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