uploadurl

package
v0.61.0 Latest Latest
Warning

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

Go to latest
Published: Oct 26, 2026 License: Apache-2.0 Imports: 12 Imported by: 1 module, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package uploadurl issues short-lived URLs that accept a file for one file form field in a single PUT request. Clients that cannot run the chunked upload protocol of the Web UI, such as AI agents using curl, use these URLs.

Index

Constants

View Source
const DefaultTTL = 30 * time.Minute

DefaultTTL is how long an issued upload URL accepts uploads.

View Source
const StatusProcessing = "PROCESSING"

StatusProcessing is the upload status reported while a file is being stored or verified.

Variables

View Source
var (
	// ErrUnknownURL is returned when an upload URL token was never issued or has already been claimed.
	ErrUnknownURL = errors.New("unknown upload URL")
	// ErrExpiredURL is returned when an upload URL token is used after it expires.
	ErrExpiredURL = errors.New("upload URL has expired")
)

Functions

This section is empty.

Types

type Grant

type Grant struct {
	// URL is the address that accepts the file body with a PUT request.
	URL string
	// FieldID is the ID of the file form field that receives the file.
	FieldID string
	// MaxSizeBytes is the largest file size the URL accepts.
	MaxSizeBytes int64
	// ExpiresAt is the time after which the URL rejects uploads.
	ExpiresAt time.Time
}

Grant describes an issued upload URL.

type Handler

type Handler struct {
	// contains filtered or unexported fields
}

Handler stores files sent to upload URLs. It uses the same persistence and verification path as Web UI uploads.

func NewHandler

func NewHandler(issuer *Issuer, manager *upload.FileParameterUploadManager) *Handler

NewHandler returns a Handler that accepts uploads for URLs issued by issuer and stores them with manager.

func (*Handler) ServeUpload

func (h *Handler) ServeUpload(w http.ResponseWriter, r *http.Request, urlToken string)

ServeUpload stores the request body as the file of the field that urlToken was issued for. The request must declare the body size in Content-Length.

type Issuer

type Issuer struct {
	// contains filtered or unexported fields
}

Issuer issues upload URLs and claims the URL tokens in them. Each URL is bound to the upload token of one file form field.

func NewIssuer

func NewIssuer(baseURL string, maxSizeBytes int64, ttl time.Duration) *Issuer

NewIssuer returns an Issuer whose URLs are baseURL followed by a random URL token. baseURL must end with the path that routes to Handler, including the trailing slash.

func (*Issuer) Issue

func (i *Issuer) Issue(uploadTokenID, fieldID string) Grant

Issue returns a new upload URL that stores the file for the upload token uploadTokenID of the file form field fieldID.

Jump to

Keyboard shortcuts

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