upload

package
v1.2.0 Latest Latest
Warning

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

Go to latest
Published: Aug 26, 2016 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func HandleS3Uploads added in v1.2.0

func HandleS3Uploads(bucket string) httprouter.Handle

HandleS3Uploads returns a handler that serves static files from Amazon S3. If the file does not exist on the S3, a 404 is returned.

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
}

FileInfo represents information about a single file

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.

Jump to

Keyboard shortcuts

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