contentstore

package
v0.0.0-...-0fdad32 Latest Latest
Warning

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

Go to latest
Published: Nov 14, 2024 License: MIT Imports: 22 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func S3UsePathStyle

func S3UsePathStyle(opts *s3.Options)

S3UsePathStyle is a s3.config function that allows you to enable the client to use path-style addressing, i.e., https:// s3.amazonaws.com/BUCKET/KEY . By default, the S3 client will use virtual hosted bucket addressing when possible( https://BUCKET.s3.amazonaws.com/KEY ).

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) Name

func (d *DevStore) Name() string

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

func (*DevStore) UploadWithName

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

UploadWithName is unsupported for the devstore.

type GCPStore

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

func NewGCPStore

func NewGCPStore(bucketName string) (*GCPStore, error)

NewGCPStore provides a mechanism to initialize a GCP client

func (*GCPStore) Delete

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

Delete removes the indicated file from GCP

func (*GCPStore) Name

func (s *GCPStore) Name() string

func (*GCPStore) Read

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

Read retrieves the indicated file from Google Cloud

func (*GCPStore) Upload

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

Upload stores a file in the Google Cloud bucket configured when the gcpStore was created

func (*GCPStore) UploadWithName

func (s *GCPStore) UploadWithName(key string, data io.Reader) error

UploadWithName is a test/dev helper that places a file on Google Cloud with a given name This is not intended for general use.

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) Name

func (d *MemStore) Name() string

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

type Presigner

type Presigner struct {
	PresignClient *s3.PresignClient
}

func (Presigner) GetObject

func (presigner Presigner) GetObject(
	bucketName string, objectKey string, minutes time.Duration) (*v4.PresignedHTTPRequest, error)

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, optsFns ...func(*s3.Options)) (*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) Name

func (d *S3Store) Name() string

func (*S3Store) Read

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

Read retrieves the indicated file from Amazon S3

func (*S3Store) SendURLData

func (s *S3Store) SendURLData(key string) (*URLData, error)

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

func (*S3Store) UploadWithName

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

UploadWithName is a test/dev helper that places a file on S3 with a given name This is not intended for general use.

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)
	UploadWithName(key string, data io.Reader) error
	Read(key string) (io.Reader, error)
	Delete(key string) error
	Name() string
}

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

Note that UploadWithName is only intended for development and testing. This should not be used directly.

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

type URLData

type URLData struct {
	Url            string    `json:"url"`
	ExpirationTime time.Time `json:"expirationTime"`
}

Jump to

Keyboard shortcuts

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