storage

package
v0.10.0 Latest Latest
Warning

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

Go to latest
Published: Mar 13, 2026 License: MIT Imports: 9 Imported by: 0

Documentation

Overview

Package storage provides local file storage for sandbox execution outputs.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type File

type File struct {
	Key          string `json:"key"`
	Size         int64  `json:"size"`
	LastModified string `json:"last_modified,omitempty"`
	URL          string `json:"url,omitempty"`
}

File represents a stored file's metadata.

type Service

type Service interface {
	// Upload stores a file scoped to an execution and returns its relative key and public URL.
	Upload(executionID, name string, body io.Reader) (relativeKey, url string, err error)
	// List returns files scoped to an execution, optionally filtered by prefix.
	List(executionID, prefix string) ([]File, error)
	// GetURL returns the public URL for a file scoped to an execution.
	GetURL(executionID, key string) string
	// ServeFile serves a stored file over HTTP.
	ServeFile(w http.ResponseWriter, r *http.Request, filePath string)
}

Service provides file storage backed by an afero filesystem.

func New

func New(fs afero.Fs, baseDir, baseURL string) Service

New creates a new storage service.

fs is the filesystem implementation (afero.OsFs for production, afero.MemMapFs for tests). baseDir is the root directory for stored files. baseURL is the server's public base URL used to construct file URLs.

Jump to

Keyboard shortcuts

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