filestorage

package
v0.0.0-...-6e8831f Latest Latest
Warning

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

Go to latest
Published: Feb 11, 2020 License: MIT Imports: 18 Imported by: 2

Documentation

Overview

Package filestorage provides a file storage service that manages public web app files e.g. user-uploaded avatars.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AmazonS3

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

AmazonS3 is an Amazon S3 file storage.

func NewAmazonS3

func NewAmazonS3(accessKey, secretKey, region, bucket string) (*AmazonS3, error)

NewAmazonS3 returns a new Amazon S3 file storage.

func (*AmazonS3) Remove

func (s *AmazonS3) Remove(path string) error

Remove removes the file with the given path.

func (*AmazonS3) Save

func (s *AmazonS3) Save(path string, r io.Reader) error

Save saves data from r to file with the given path.

func (*AmazonS3) URL

func (s *AmazonS3) URL(path string) string

URL returns an URL of the file with the given path.

type CovenantS3

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

CovenantS3 is an CovenantS3 file storage.

func NewCovenantS3

func NewCovenantS3(dsn, configFile, masterKey, httpEndpoint, bucket string) (*CovenantS3, error)

NewCovenantS3 returns a new CovenantS3 file storage.

func (*CovenantS3) GetHTTPHandler

func (s *CovenantS3) GetHTTPHandler(stripPrefix string) http.HandlerFunc

GetHTTPHandler returns the static http.HandlerFunc

func (*CovenantS3) Migrate

func (s *CovenantS3) Migrate() error

Migrate ensures the tables is created.

func (*CovenantS3) Remove

func (s *CovenantS3) Remove(path string) error

Remove removes the file with the given path.

func (*CovenantS3) Save

func (s *CovenantS3) Save(path string, r io.Reader) error

Save saves data from r to file with the given path.

func (*CovenantS3) URL

func (s *CovenantS3) URL(path string) string

URL returns an URL of the file with the given path.

type FileStorage

type FileStorage interface {
	// Save saves data from r to file with the given path.
	Save(path string, r io.Reader) error

	// Remove removes the file with the given path.
	Remove(path string) error

	// URL returns an URL of the file with the given path.
	URL(path string) string
}

FileStorage manages files uploaded by users.

type GoogleCloudStorage

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

GoogleCloudStorage is a GCS-based file storage.

func NewGoogleCloudStorage

func NewGoogleCloudStorage(serviceAccountFile, bucket string) (*GoogleCloudStorage, error)

NewGoogleCloudStorage returns a new GoogleCloudStorage file storage.

func (*GoogleCloudStorage) Remove

func (s *GoogleCloudStorage) Remove(path string) error

Remove removes the file with the given path.

func (*GoogleCloudStorage) Save

func (s *GoogleCloudStorage) Save(path string, r io.Reader) error

Save saves data from r to file with the given path.

func (*GoogleCloudStorage) URL

func (s *GoogleCloudStorage) URL(path string) string

URL returns an URL of the file with the given path.

type Local

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

Local is a local file storage.

func NewLocal

func NewLocal(dir, url string) (*Local, error)

NewLocal returns a new local file storage.

func (*Local) Remove

func (s *Local) Remove(path string) error

Remove removes the file with the given path.

func (*Local) Save

func (s *Local) Save(path string, r io.Reader) error

Save saves data from r to file with the given path.

func (*Local) URL

func (s *Local) URL(path string) string

URL returns an URL of the file with the given path.

Jump to

Keyboard shortcuts

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