storage

package
v1.0.7 Latest Latest
Warning

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

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

Documentation

Overview

Package storage defines common types & interfaces for programmatic storage implementations.

Index

Constants

This section is empty.

Variables

View Source
var ErrNoSuchFile = errors.New("no such file")

Functions

func DownloadByURLThenUpload

func DownloadByURLThenUpload(ctx context.Context, s Storage, url string, name string) error

DownloadByURLThenUpload performs a file download with default client, then uploads result to specified location in bucket.

Types

type ObjectAttributes

type ObjectAttributes struct {
	ETag           string     `json:"etag"`
	ExpirationTime *time.Time `json:"expirationTime"`
	ContentType    string     `json:"contentType"`
	UpdatedTime    time.Time  `json:"updatedTime"`
	Size           int64      `json:"size"`
}

type Storage

type Storage interface {
	io.Closer
	// DownloadFileReader creates full file download reader.
	DownloadFileReader(ctx context.Context, name string) (io.ReadCloser, error)

	// DownloadFileBytes downloads the file using file name.
	DownloadFileBytes(ctx context.Context, name string) ([]byte, error)

	// DownloadRangeReader creates range file download reader.
	DownloadRangeReader(
		ctx context.Context,
		name string,
		offset int64,
		length int64,
	) (io.ReadCloser, error)

	// Downloader creates [io.ReadSeeker] as file download reader.
	//
	// Useful for serving files where full content download ahead of time is expensive
	// (e.g. with [http.ServeContent]).
	Downloader(ctx context.Context, name string, size int64) io.ReadSeeker

	// UploadFile uploads the file to the storage using file name and provided reader.
	UploadFile(ctx context.Context, name string, r io.Reader) error

	// UpdateFile updates object attributes.
	UpdateFile(ctx context.Context, name string, attrs UpdateAttributes) error

	// Attributes retrieves object attributes.
	Attributes(ctx context.Context, name string) (*ObjectAttributes, error)

	// DeleteFile removes file from the storage.
	DeleteFile(ctx context.Context, name string) error
}

type UpdateAttributes

type UpdateAttributes struct {
	ContentType string
	CustomTime  time.Time
}

Jump to

Keyboard shortcuts

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