contentstore

package
v0.0.0-...-87f5de6 Latest Latest
Warning

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

Go to latest
Published: Jul 7, 2020 License: MIT Imports: 17 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ContentKeys

type ContentKeys struct {
	Full      string
	Thumbnail string
}

ContentKeys stores the location/path of the original content, as well as the thumbnail/preview location

type DevStore

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

DevStore is the backing structure needed to interact with a local, temporary image store

func NewDevStore

func NewDevStore() (*DevStore, error)

NewDevStore constructs a basic DevStore / local temporary store

func (*DevStore) Delete

func (d *DevStore) Delete(key string) error

Delete removes files in in your OS's temp directory

func (*DevStore) Read

func (d *DevStore) Read(key string) (io.Reader, error)

func (*DevStore) Upload

func (d *DevStore) Upload(data io.Reader) (string, error)

Upload stores files in your OS's temp directory

type MemStore

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

MemStore is the backing structure needed to interact with local memory -- for unit/integration testing purposes only

func NewMemStore

func NewMemStore() (*MemStore, error)

NewMemStore is the constructor for MemStore

func (*MemStore) Delete

func (d *MemStore) Delete(key string) error

Delete removes files in in your OS's temp directory

func (*MemStore) Read

func (d *MemStore) Read(key string) (io.Reader, error)

func (*MemStore) Upload

func (d *MemStore) Upload(data io.Reader) (key string, err error)

Upload stores content in memory

func (*MemStore) UploadWithName

func (d *MemStore) UploadWithName(key string, data io.Reader) error

UploadWithName writes the given data to the given memory key -- this can allow for re-writing/replacing data if names are not unique

Note: to avoid overwriting random keys, DO NOT use uuids as they key Note 2: This is NOT part of the standard ContentStore interface

type S3Store

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

S3Store is the backing structure needed to interact with an Amazon S3 storage service TODO: this can be unexported

func NewS3Store

func NewS3Store(bucketName string, region string) (*S3Store, error)

NewS3Store provides a mechanism to initialize an S3 bucket in a particular region

func (*S3Store) Delete

func (s *S3Store) Delete(key string) error

Delete removes files in in your OS's temp directory

func (*S3Store) Read

func (s *S3Store) Read(key string) (io.Reader, error)

Read retrieves the indicated file from Amazon S3

func (*S3Store) Upload

func (s *S3Store) Upload(data io.Reader) (string, error)

Upload stores a file in the Amazon S3 bucket configured when the S3 store was created

type Storable

type Storable interface {
	ProcessPreviewAndUpload(Store) (ContentKeys, error)
}

Storable represents content in a yet-to-be-uploaded state. The basic workflow when using this is to create a new instance, then immediately call ProcessPreviewAndUpload, which will both generate preview content (e.g. a resized image), and upload both the provided content, plus the preview to the provided Store

func NewBlob

func NewBlob(data io.Reader) Storable

NewBlob returns a Storable that deals with binary/non-binary content that does not lend itself to a preview/proxy

func NewImage

func NewImage(data io.Reader) Storable

NewImage returns a Storable that deals specifically with images (png / jpg)

type Store

type Store interface {
	Upload(data io.Reader) (string, error)
	Read(key string) (io.Reader, error)
	Delete(key string) error
}

Store provides a generic interface into interacting with the underlying storage service

Upload stores the provided file/bytes into the storage service, returning the location of that file or any error that may have occurred

Read retrieves the raw bytes from the storage service, given a key obtained by Upload

Jump to

Keyboard shortcuts

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