storage

package
v1.7.0 Latest Latest
Warning

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

Go to latest
Published: Mar 15, 2026 License: GPL-3.0 Imports: 12 Imported by: 0

Documentation

Overview

Package storage provides file storage abstractions for minimaldoc-server.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type File

type File struct {
	ID          string
	Filename    string
	ContentType string
	Size        int64
	StoragePath string
	URL         string
	UploadedAt  time.Time
}

File represents an uploaded file.

type LocalStorage

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

LocalStorage implements Storage using the local filesystem.

func NewLocalStorage

func NewLocalStorage(cfg config.StorageConfig) (*LocalStorage, error)

NewLocalStorage creates a local filesystem storage provider.

func (*LocalStorage) Delete

func (s *LocalStorage) Delete(ctx context.Context, path string) error

Delete removes a file from the local filesystem.

func (*LocalStorage) URL

func (s *LocalStorage) URL(path string) string

URL returns the public URL for a storage path.

func (*LocalStorage) Upload

func (s *LocalStorage) Upload(ctx context.Context, filename string, contentType string, reader io.Reader) (string, string, error)

Upload stores a file to the local filesystem.

type S3Storage

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

S3Storage implements Storage using S3-compatible object storage.

func (*S3Storage) Delete

func (s *S3Storage) Delete(ctx context.Context, path string) error

Delete removes a file from S3.

func (*S3Storage) URL

func (s *S3Storage) URL(path string) string

URL returns the public URL for a storage path.

func (*S3Storage) Upload

func (s *S3Storage) Upload(ctx context.Context, filename string, contentType string, reader io.Reader) (string, string, error)

Upload stores a file to S3.

type Storage

type Storage interface {
	// Upload stores a file and returns its public URL.
	Upload(ctx context.Context, filename string, contentType string, reader io.Reader) (url string, path string, err error)

	// Delete removes a file by its storage path.
	Delete(ctx context.Context, path string) error

	// URL returns the public URL for a storage path.
	URL(path string) string
}

Storage defines the interface for file storage operations.

func New

func New(cfg config.StorageConfig) (Storage, error)

New creates a storage provider based on configuration.

func NewS3Storage

func NewS3Storage(cfg config.StorageConfig) (Storage, error)

NewS3Storage creates an S3 storage provider.

Jump to

Keyboard shortcuts

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