upload

package
v0.1.20 Latest Latest
Warning

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

Go to latest
Published: Jul 30, 2026 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Overview

Package upload provides simple helpers for parsing multipart file uploads and parsing simple skill definition payloads used by the UI.

This package intentionally uses only the Go standard library so it can be used in low-dependency, domain-agnostic layers of the project.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DetectMediaType

func DetectMediaType(data []byte) string

DetectMediaType attempts to identify common media types by inspecting the initial bytes of the provided data. Returns an empty string when the type is unknown.

func ToBase64

func ToBase64(f File) string

ToBase64 returns the base64 encoding of the file's data.

Types

type File

type File struct {
	Name      string
	Data      []byte
	MediaType string
	Size      int64
}

File represents an uploaded file.

func ParseMultipartForm

func ParseMultipartForm(r *http.Request, maxMemory int64) ([]File, error)

ParseMultipartForm parses a multipart form from the provided request. maxMemory is passed to r.ParseMultipartForm and controls how much data is kept in memory before being written to temporary files.

type Skill

type Skill struct {
	Name        string `json:"name"`
	Description string `json:"description"`
	Template    string `json:"template"`
}

Skill represents a simple skill definition uploaded by the UI.

func ParseSkill

func ParseSkill(data []byte) (*Skill, error)

ParseSkill attempts to parse a skill definition from JSON data. The format is intentionally small and JSON-only to avoid adding dependencies for YAML parsing. If YAML support is required later, the caller may convert before calling into this package.

Jump to

Keyboard shortcuts

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