tempfiles

package
v1.4.2 Latest Latest
Warning

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

Go to latest
Published: Oct 18, 2026 License: MIT Imports: 11 Imported by: 0 modules, 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

Index

Constants

View Source
const (
	DefaultBaseURL = "https://www.mythicalsystems.org"

	PartSizeBytes      = 67108864
	AnonymousMaxBytes  = 16106127360
	APIKeyMaxBytes     = 32212254720
	BackgroundMinBytes = 256 << 20 // 256 MiB
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

type Client struct {
	BaseURL string
	Token   string
	HTTP    *http.Client
}

Client talks to the temp uploads API and the multipart upload endpoint.

func New

func New(token string) *Client

New returns a Client with sensible timeouts for large multipart uploads.

func (*Client) Complete

func (c *Client) Complete(ctx context.Context, publicID string, req CompleteRequest) (*CompleteResponse, error)

Complete finalizes the multipart upload.

func (*Client) Init

func (c *Client) Init(ctx context.Context, req InitRequest) (*InitResponse, error)

Init creates a multipart upload session.

func (*Client) MaxBytes

func (c *Client) MaxBytes() int64

MaxBytes returns the size limit for the current auth mode.

func (*Client) Upload

func (c *Client) Upload(ctx context.Context, filename string, size int64, ttlDays int, password, deleteKey string, reader io.Reader) (*Result, error)

Upload streams reader to temp uploads and returns the share result.

type CompleteRequest

type CompleteRequest struct {
	Parts []CompletedPart `json:"parts"`
}

CompleteRequest is the JSON body for POST /api/temp-files/{id}/complete.

type CompleteResponse

type CompleteResponse struct {
	Success           bool   `json:"success"`
	PublicID          string `json:"public_id"`
	PageURL           string `json:"page_url"`
	DownloadPath      string `json:"download_path"`
	ExpiresAt         string `json:"expires_at"`
	Size              int64  `json:"size"`
	OriginalName      string `json:"original_name"`
	PasswordProtected bool   `json:"password_protected"`
	DownloadURL       string `json:"download_url"`
	Error             string `json:"error"`
	Message           string `json:"message"`
}

CompleteResponse is returned by complete.

type CompletedPart

type CompletedPart struct {
	PartNumber int    `json:"part_number"`
	ETag       string `json:"etag"`
}

CompletedPart is sent to complete.

type InitRequest

type InitRequest struct {
	Filename  string `json:"filename"`
	Size      int64  `json:"size"`
	TTLDays   int    `json:"ttl_days"`
	Password  string `json:"password,omitempty"`
	DeleteKey string `json:"delete_key,omitempty"`
}

InitRequest is the JSON body for POST /api/temp-files.

type InitResponse

type InitResponse struct {
	Success           bool   `json:"success"`
	PublicID          string `json:"public_id"`
	PartSize          int64  `json:"part_size"`
	PartCount         int    `json:"part_count"`
	Parts             []Part `json:"parts"`
	DeleteKey         string `json:"delete_key"`
	DeleteToken       string `json:"delete_token"`
	PasswordProtected bool   `json:"password_protected"`
	ExpiresAt         string `json:"expires_at"`
	CompleteURL       string `json:"complete_url"`
	PageURL           string `json:"page_url"`
	DownloadPath      string `json:"download_path"`
	Error             string `json:"error"`
	Message           string `json:"message"`
}

InitResponse is returned by POST /api/temp-files.

type Part

type Part struct {
	PartNumber int    `json:"part_number"`
	URL        string `json:"url"`
}

Part describes a single multipart upload URL from init.

type Result

type Result struct {
	PublicID          string `json:"public_id"`
	URL               string `json:"url"`
	DeleteKey         string `json:"delete_key"`
	ExpiresAt         string `json:"expires_at"`
	PasswordProtected bool   `json:"password_protected"`
	Size              int64  `json:"size"`
	Filename          string `json:"filename"`
}

Result is the final share result returned to callers.

Jump to

Keyboard shortcuts

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