filestore

package
v0.0.0-...-c32710b Latest Latest
Warning

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

Go to latest
Published: Dec 29, 2020 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func MakeGetFileEndpoint

func MakeGetFileEndpoint(f FileService) endpoint.Endpoint

MakeGetFileEndpoint returns an endpoint via the passed service. Primarily useful in a server.

Types

type FileItem

type FileItem struct {
	FileName   string
	FolderName string
	MimeType   string
	Payload    []byte
}

FileItem represents the data-structure of a saved file

func (FileItem) String

func (f FileItem) String() string

type FileService

type FileService interface {
	InitClient() (err error)
	SaveFile(file FileItem) (err error)
	GetFile(filePath string) (item FileItem, err error)
	DeleteFile(filePath string) (err error)
}

FileService defines an interface for backend file services

func NewService

func NewService(logger logging.Logger, config S3Config) FileService

NewService returns a new instance of the fileservice

type GetFilePathRequest

type GetFilePathRequest struct {
	Path string
}

GetFilePathRequest is used to retrieve a file by a given path

type GetFilePathResponse

type GetFilePathResponse struct {
	MimeType string `json:"mimeType,omitempty"`
	Payload  []byte `json:"payload,omitempty"`
	Err      error  `json:"err,omitempty"`
}

GetFilePathResponse returns a file payload

func (GetFilePathResponse) Failed

func (r GetFilePathResponse) Failed() error

Failed implements endpoint.Failer.

type S3Config

type S3Config struct {
	Region string
	Bucket string
	Key    string
	Secret string
}

S3Config defines the parameters to interact with S3 storage

type ServiceMiddleware

type ServiceMiddleware func(FileService) FileService

ServiceMiddleware describes a service (as opposed to endpoint) middleware. it is used to intercept the method execution and perform actions before/after the serivce method execution

func ServiceLoggingMiddleware

func ServiceLoggingMiddleware(logger logging.Logger) ServiceMiddleware

ServiceLoggingMiddleware takes a logger as a dependency and returns a ServiceLoggingMiddleware.

Jump to

Keyboard shortcuts

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