Help us shape the future of Go! Take the 2026 Go Developer Survey

fileupload

package
v0.32.2 Latest Latest
Warning

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

Go to latest
Published: Oct 21, 2026 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrNoFilesProvided = uploadrevision.ErrNoFilesUploaded
	ErrEmptyOrgID      = uploadrevision.ErrEmptyOrgID
	ErrEmptyRevisionID = uploadrevision.ErrEmptyRevisionID
)

Sentinel errors for common conditions.

Functions

This section is empty.

Types

type Client

type Client interface {
	CreateRevisionFromChan(ctx context.Context, paths <-chan string, rootPath string) (UploadResult, error)
}

Client defines the interface for the high level file upload client.

func NewClient

func NewClient(httpClient *http.Client, cfg Config, opts ...Option) Client

NewClient creates a new high-level file upload client.

type Config

type Config struct {
	BaseURL string
	OrgID   OrgID
}

Config contains configuration for the file upload client.

type ContentTranscoder added in v0.9.0

type ContentTranscoder func(content []byte) ([]byte, error)

ContentTranscoder transforms a file's content before it is uploaded. The returned content is the one filtered by the file size limit and uploaded.

type FakeClient

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

func NewFakeClient

func NewFakeClient() *FakeClient

NewFakeClient creates a new fake client.

func (*FakeClient) CreateRevisionFromChan

func (f *FakeClient) CreateRevisionFromChan(ctx context.Context, paths <-chan string, rootDir string) (UploadResult, error)

func (*FakeClient) GetLastRevisionID

func (f *FakeClient) GetLastRevisionID() RevisionID

GetLastRevisionID returns the ID of the most recent revision created.

func (*FakeClient) GetRevisionPaths

func (f *FakeClient) GetRevisionPaths(revID RevisionID) []string

func (*FakeClient) GetUploadCount

func (f *FakeClient) GetUploadCount() int

GetUploadCount returns the number of uploads that have occurred.

func (*FakeClient) UploadOccurred

func (f *FakeClient) UploadOccurred() bool

UploadOccurred returns true if at least one upload has been performed.

func (*FakeClient) WithError

func (f *FakeClient) WithError(err error) *FakeClient

WithError configures the fake to return an error.

type FileAccessError

type FileAccessError = uploadrevision.FileAccessError

FileAccessError indicates a file access permission issue.

type FileCountLimitError

type FileCountLimitError = uploadrevision.FileCountLimitError

FileCountLimitError indicates too many files were provided.

type FilePathLengthLimitError

type FilePathLengthLimitError = uploadrevision.FilePathLengthLimitError

FilePathLengthLimitError indicates a file's path exceeds the maximum allowed size.

type FileSizeLimitError

type FileSizeLimitError = uploadrevision.FileSizeLimitError

FileSizeLimitError indicates a file exceeds the maximum allowed size.

type HTTPClient

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

HTTPClient provides high-level file upload functionality.

func (*HTTPClient) CreateRevisionFromChan

func (c *HTTPClient) CreateRevisionFromChan(ctx context.Context, paths <-chan string, rootPath string) (UploadResult, error)

CreateRevisionFromChan uploads multiple paths from a channel (files paths only, file paths are uploaded relative to rootPath), returning a revision ID. This is a convenience method that creates, uploads, and seals a revision.

type HTTPError

type HTTPError = uploadrevision.HTTPError

HTTPError indicates an HTTP request/response error.

type MultipartError

type MultipartError = uploadrevision.MultipartError

MultipartError indicates an issue with multipart request handling.

type Option

type Option func(*HTTPClient)

Option allows customizing the Client during construction.

func WithContentTranscoder added in v0.9.0

func WithContentTranscoder(transcode ContentTranscoder) Option

WithContentTranscoder allows transcoding each file's content before it is uploaded, e.g. to UTF-8. Files the transcoder fails on are skipped.

func WithLogger

func WithLogger(logger *zerolog.Logger) Option

WithLogger allows injecting a custom logger instance.

func WithPathEncoder added in v0.9.0

func WithPathEncoder(encode PathEncoder) Option

WithPathEncoder allows encoding each file's upload path before it is sent, e.g. to URI-encode it. It does not affect the filesystem path the file is read from.

func WithUploadRevisionSealableClient

func WithUploadRevisionSealableClient(client uploadrevision.SealableClient) Option

WithUploadRevisionSealableClient allows injecting a custom low-level client (primarily for testing).

type OrgID

type OrgID = uploadrevision.OrgID

OrgID represents an organization identifier.

type PathEncoder added in v0.9.0

type PathEncoder func(path string) string

PathEncoder transforms a file's upload path, relative to the root directory. The encoded path is the one filtered by the path length limit and reported for skipped files.

type RevisionID

type RevisionID = uploadrevision.RevisionID

RevisionID represents a revision identifier.

type SkippedFile

type SkippedFile struct {
	Path   string
	Reason error
}

SkippedFile represents a file that was skipped. It includes the skipped file's path and the reason it was skipped.

type SpecialFileError

type SpecialFileError = uploadrevision.SpecialFileError

SpecialFileError indicates a path points to a special file (device, pipe, socket, etc.) instead of a regular file.

type TotalPayloadSizeLimitError

type TotalPayloadSizeLimitError = uploadrevision.TotalPayloadSizeLimitError

TotalPayloadSizeLimitError indicates the total size of all files exceeds the maximum allowed payload size.

type UploadResult

type UploadResult struct {
	RevisionID         RevisionID    // The ID of the revision which was created.
	UploadedFilesCount int           // The number of uploaded files.
	SkippedFiles       []SkippedFile // The list of files which were skipped.
}

UploadResult respresents the result of the upload.

Jump to

Keyboard shortcuts

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