store

package
v0.0.0-...-db8c6ed Latest Latest
Warning

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

Go to latest
Published: Feb 12, 2021 License: MIT Imports: 9 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ContentTypeInList

func ContentTypeInList(contentType string, contentTypeList []string) bool

func ModuleConfigSkeletons

func ModuleConfigSkeletons() map[string]interface{}

func ModuleNames

func ModuleNames() []string

func RegisterModule

func RegisterModule(
	serviceName string,
	module Module,
)

Types

type Config

type Config struct {
	//TODO: declare the encoding (hex?)
	NameGenerationKey string `env:"FILENAME_GENERATION_KEY"`
	StoreService      string `env:"STORE_SERVICE"`

	Modules map[string]interface{} `env:",map,squash"`

	ImagesBaseURL string `env:"IMAGES_BASE_URL"`
}

Config File Core cofiguration

func ConfigFromEnv

func ConfigFromEnv(envPrefix string) (*Config, error)

ConfigFromEnv populate the configuration by looking up the environment variables.

func ConfigSkeleton

func ConfigSkeleton() Config

type Module

type Module struct {
	// ServiceConfigSkeleton returns an instance of config used to initialize
	// the service. This skeleton contains a config structure.
	ServiceConfigSkeleton func() ServiceConfig

	// NewService create a storage service backend connection. This is
	// usually initialize the client of the object storage.
	NewService func(config ServiceConfig) (Service, error)
}

Module contains attributes which describe a storage module.

type Service

type Service interface {
	PutObject(objectKey string, content io.Reader) (publicURL string, err error)
}

func NewServiceClient

func NewServiceClient(
	serviceName string,
	config interface{},
) (Service, error)

type ServiceConfig

type ServiceConfig interface{}

type Store

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

Store contains business logic of a file service.

func New

func New(config Config) (*Store, error)

New instantiates a file service.

func (*Store) GenerateName

func (mediaStore *Store) GenerateName(stream io.Reader) string

GenerateName is used to generate a name, for file name or other identifier, based on the content. It utilizes hash so the result could be used to prevent duplicates when storing the media object.

func (*Store) Upload

func (mediaStore *Store) Upload(
	mediaName string,
	contentSource io.Reader,
	mediaType mediapb.MediaType,
) (publicURL string, err error)

Upload uploads a file

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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