Documentation ¶
Overview ¶
This file is subject to the terms and conditions defined in file 'LICENSE.txt', which is part of this source code package.
This file is subject to the terms and conditions defined in file 'LICENSE.txt', which is part of this source code package.
Index ¶
- Constants
- func ComputeHash(reader io.Reader, bufferSize int) (string, error)
- type MultipartBuilder
- func (mb *MultipartBuilder) AddBytes(partName, fileName, contentType string, data []byte) error
- func (mb *MultipartBuilder) AddFile(partName, filePath, contentType string) error
- func (mb *MultipartBuilder) AddProtobuf(partName string, pb interface{}) error
- func (mb *MultipartBuilder) Finalize() error
- func (mb *MultipartBuilder) GetBoundary() string
- type MultipartReader
- type PartMetadata
Constants ¶
const DefaultBufferSize = 5 * 1024 * 1024 // 5 MB
DefaultBufferSize defines a default buffer size (5 MB) for writing parts.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type MultipartBuilder ¶
type MultipartBuilder struct {
// contains filtered or unexported fields
}
MultipartBuilder is responsible for building multipart data with writers and buffer size.
func NewMultipartBuilder ¶
func NewMultipartBuilder(w io.Writer, bufferSize int) (*MultipartBuilder, error)
NewMultipartBuilder initializes a new MultipartBuilder using an io.Writer and buffer size.
func (*MultipartBuilder) AddBytes ¶
func (mb *MultipartBuilder) AddBytes(partName, fileName, contentType string, data []byte) error
AddBytes writes a file (provided as bytes) into the multipart builder with the given filename and MIME type.
func (*MultipartBuilder) AddFile ¶
func (mb *MultipartBuilder) AddFile(partName, filePath, contentType string) error
AddFile writes the content of a file as a part of the multipart stream with Content-Size and Content-Hash headers.
func (*MultipartBuilder) AddProtobuf ¶
func (mb *MultipartBuilder) AddProtobuf(partName string, pb interface{}) error
AddProtobuf writes a single or slice of Protobuf messages as a part of the multipart stream, including Content-Size and Content-Hash headers.
func (*MultipartBuilder) Finalize ¶
func (mb *MultipartBuilder) Finalize() error
Finalize writes the ending boundary and closes the multipart writer.
func (*MultipartBuilder) GetBoundary ¶
func (mb *MultipartBuilder) GetBoundary() string
Boundary retrieves the boundary used by the multipart writer.
type MultipartReader ¶
type MultipartReader struct {
// contains filtered or unexported fields
}
MultipartReader reads multipart data from a stream and supports configurable buffer size.
func NewMultipartReader ¶
NewMultipartReader creates a new instance of MultipartReader.
func (*MultipartReader) MetadataJSON ¶
func (mr *MultipartReader) MetadataJSON(w io.Writer) error
MetadataJSON streams the JSON representation of the metadata for all parts in the multipart message.
type PartMetadata ¶
type PartMetadata struct { PartName string `json:"part_name"` PartType string `json:"part_type"` Headers map[string]interface{} `json:"headers"` }
PartMetadata describes metadata for each part of the multipart message.