asset

package
v0.4.1 Latest Latest
Warning

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

Go to latest
Published: Jan 28, 2016 License: Apache-2.0 Imports: 16 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type FileStore

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

FileStore implements Store by storing files on file system

func NewFileStore

func NewFileStore(dir, prefix, secret string, public bool) *FileStore

func (*FileStore) GetFileReader

func (s *FileStore) GetFileReader(name string) (io.ReadCloser, error)

func (*FileStore) IsSignatureRequired

func (s *FileStore) IsSignatureRequired() bool

func (*FileStore) ParseSignature

func (s *FileStore) ParseSignature(signed string, name string, expiredAt time.Time) (valid bool, err error)

func (*FileStore) PutFileReader

func (s *FileStore) PutFileReader(name string, src io.Reader, length int64, contentType string) error

PutFileReader stores a file from reader onto file system

func (*FileStore) SignedURL

func (s *FileStore) SignedURL(name string) (string, error)

type S3Store

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

S3Store implements Store by storing files on S3

func NewS3Store

func NewS3Store(accessKey, secretKey, regionName, bucketName string, public bool) (*S3Store, error)

NewS3Store returns a new S3Store

func (*S3Store) GetFileReader

func (s *S3Store) GetFileReader(name string) (io.ReadCloser, error)

func (*S3Store) IsSignatureRequired

func (s *S3Store) IsSignatureRequired() bool

func (*S3Store) PutFileReader

func (s *S3Store) PutFileReader(name string, src io.Reader, length int64, contentType string) error

PutFileReader uploads a file to s3 with content from io.Reader

func (*S3Store) SignedURL

func (s *S3Store) SignedURL(name string) (string, error)

SignedURL return a signed s3 URL with expiry date

type SignatureParser

type SignatureParser interface {
	ParseSignature(signed string, name string, expiredAt time.Time) (valid bool, err error)
}

SignatureParser parses a signed signature string

type Store

type Store interface {
	GetFileReader(name string) (io.ReadCloser, error)
	PutFileReader(name string, src io.Reader, length int64, contentType string) error
}

Store specify the interfaces of an asset store

type URLSigner

type URLSigner interface {
	// SignedURL returns a url with access to the named file. If asset
	// store is private, the returned URL is a signed one, allowing access
	// to asset for a short period.
	SignedURL(name string) (string, error)
	IsSignatureRequired() bool
}

URLSigner signs a signature and returns a URL accessible to that asset.

Jump to

Keyboard shortcuts

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