upload

package
v0.8.0 Latest Latest
Warning

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

Go to latest
Published: Jun 12, 2016 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Driver

type Driver interface {
	Save(filePath string, data []byte) error
	List(dirPath string) ([]FileInfo, error)
	Delete(filePath string) error
	DeleteAll(dirPath string) error
}

Driver represents an abstraction layer for handling file uploads

type FileInfo

type FileInfo struct {
	Name         string
	URL          string
	ThumbnailURL string
}

type FileSystemDriver

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

FileSystemDriver is an implementation of Driver that uses the local file system.

func NewFileSystemDriver

func NewFileSystemDriver(cfg *conf.Config) FileSystemDriver

NewFileSystemDriver constucts a FileSystemDriver.

func (FileSystemDriver) Delete

func (u FileSystemDriver) Delete(filePath string) error

Delete deletes the file at the specified path, if it exists.

func (FileSystemDriver) DeleteAll

func (u FileSystemDriver) DeleteAll(dirPath string) error

DeleteAll deletes all files at or under the specified directory path.

func (FileSystemDriver) List

func (u FileSystemDriver) List(dirPath string) ([]FileInfo, error)

List retrieves information about all uploaded files under the specified directory.

func (FileSystemDriver) Save

func (u FileSystemDriver) Save(filePath string, data []byte) error

Save creates or overrites a file with the provided binary data.

type S3Driver

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

S3Driver is an implementation of Driver that uses the Amazon S3.

func NewS3Driver

func NewS3Driver(cfg *conf.Config) S3Driver

NewS3Driver constucts a S3Driver.

func (S3Driver) Delete

func (u S3Driver) Delete(key string) error

Delete deletes the file with the specified key, if it exists.

func (S3Driver) DeleteAll

func (u S3Driver) DeleteAll(keyPrefix string) error

DeleteAll deletes all files with the specified key prefix.

func (S3Driver) List

func (u S3Driver) List(keyPrefix string) ([]FileInfo, error)

List retrieves information about all uploaded files with the specified key prefix.

func (S3Driver) Save

func (u S3Driver) Save(filePath string, data []byte) error

Save creates or overrites a file with the provided binary data.

type S3Static

type S3Static struct {

	// Prefix is the optional prefix used to serve the static content
	Prefix string
	// contains filtered or unexported fields
}

S3Static is a middleware handler that serves static files from Amazon S3. If the file does not exist on the S3, it passes along to the next middleware in the chain.

func NewS3Static

func NewS3Static(cfg *conf.Config) *S3Static

NewS3Static returns a new instance of S3Static

func (*S3Static) ServeHTTP

func (s *S3Static) ServeHTTP(rw http.ResponseWriter, r *http.Request, next http.HandlerFunc)

Jump to

Keyboard shortcuts

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