miniorepo

package
v0.0.0-...-bd94320 Latest Latest
Warning

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

Go to latest
Published: Oct 30, 2024 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type MinioRepository

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

MinioRepository used to upload and download files. Must be initialized with New function.

func New

func New(ctx context.Context, settings Settings) (*MinioRepository, error)

New creates a new MinioRepository instance.

It takes a context.Context, and Settings to initialize the repository.

It creates a MinioRepository using the given settings, checks if the bucket exists, and creates the bucket if it doesn't.

It returns the pointer to created MinioRepository and an error.

func (MinioRepository) DeleteFile

func (r MinioRepository) DeleteFile(ctx context.Context, id string) error

DeleteFile removes a file from the Minio repository.

It takes a context and a string representing the file ID.

The file is removed from the bucket specified in the repository.

Returns an error if the deletion fails.

func (MinioRepository) GetFile

func (r MinioRepository) GetFile(
	ctx context.Context,
	meta models.Metadata,
) (io.ReadSeekCloser, error)

GetFile get file from repository.

It takes metadata containing file information like owner ID and file ID.

The file is downloaded from the bucket specified in the repository, using a filename composed of the owner ID and file ID.

Returns error if get failed. Returns io.ReadSeekCloser if get was successful.

func (MinioRepository) UploadFile

func (r MinioRepository) UploadFile(
	ctx context.Context,
	file io.Reader,
	meta models.Metadata,
) error

UploadFile uploads a file to the Minio repository.

It takes an io.Reader representing the file to be uploaded, and metadata containing file information like owner ID and file ID.

The file is uploaded to the bucket specified in the repository, using a filename composed of the owner ID and file ID.

Returns an error if the upload fails.

type Settings

type Settings struct {
	Endpoint  string
	AccessKey string
	SecretKey string
	Bucket    string
	UseSSL    bool
}

Settings used to create MinioRepository. Endpoint, AccessKey, SecretKey and Bucket are required. UseSSL defaults to false.

Jump to

Keyboard shortcuts

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