s3

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Feb 24, 2026 License: EUPL-1.2 Imports: 13 Imported by: 0

Documentation

Overview

Package s3 provides an S3-backed implementation of the io.Medium interface.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Medium

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

Medium is an S3-backed storage backend implementing the io.Medium interface.

func New

func New(bucket string, opts ...Option) (*Medium, error)

New creates a new S3 Medium for the given bucket.

func (*Medium) Append

func (m *Medium) Append(p string) (goio.WriteCloser, error)

Append opens the named file for appending. It downloads the existing content (if any) and re-uploads the combined content on Close.

func (*Medium) Create

func (m *Medium) Create(p string) (goio.WriteCloser, error)

Create creates or truncates the named file. Returns a writer that uploads the content on Close.

func (*Medium) Delete

func (m *Medium) Delete(p string) error

Delete removes a single object.

func (*Medium) DeleteAll

func (m *Medium) DeleteAll(p string) error

DeleteAll removes all objects under the given prefix.

func (*Medium) EnsureDir

func (m *Medium) EnsureDir(_ string) error

EnsureDir is a no-op for S3 (S3 has no real directories).

func (*Medium) Exists

func (m *Medium) Exists(p string) bool

Exists checks if a path exists (file or directory prefix).

func (*Medium) FileGet

func (m *Medium) FileGet(p string) (string, error)

FileGet is a convenience function that reads a file from the medium.

func (*Medium) FileSet

func (m *Medium) FileSet(p, content string) error

FileSet is a convenience function that writes a file to the medium.

func (*Medium) IsDir

func (m *Medium) IsDir(p string) bool

IsDir checks if a path exists and is a directory (has objects under it as a prefix).

func (*Medium) IsFile

func (m *Medium) IsFile(p string) bool

IsFile checks if a path exists and is a regular file (not a "directory" prefix).

func (*Medium) List

func (m *Medium) List(p string) ([]fs.DirEntry, error)

List returns directory entries for the given path using ListObjectsV2 with delimiter.

func (*Medium) Open

func (m *Medium) Open(p string) (fs.File, error)

Open opens the named file for reading.

func (*Medium) Read

func (m *Medium) Read(p string) (string, error)

Read retrieves the content of a file as a string.

func (*Medium) ReadStream

func (m *Medium) ReadStream(p string) (goio.ReadCloser, error)

ReadStream returns a reader for the file content.

func (*Medium) Rename

func (m *Medium) Rename(oldPath, newPath string) error

Rename moves an object by copying then deleting the original.

func (*Medium) Stat

func (m *Medium) Stat(p string) (fs.FileInfo, error)

Stat returns file information for the given path using HeadObject.

func (*Medium) Write

func (m *Medium) Write(p, content string) error

Write saves the given content to a file, overwriting it if it exists.

func (*Medium) WriteStream

func (m *Medium) WriteStream(p string) (goio.WriteCloser, error)

WriteStream returns a writer for the file content. Content is uploaded on Close.

type Option

type Option func(*Medium)

Option configures a Medium.

func WithClient

func WithClient(client *s3.Client) Option

WithClient sets the S3 client for dependency injection.

func WithPrefix

func WithPrefix(prefix string) Option

WithPrefix sets an optional key prefix for all operations.

Jump to

Keyboard shortcuts

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