filestorage

package
v0.0.0-...-5d38250 Latest Latest
Warning

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

Go to latest
Published: Aug 23, 2018 License: MIT Imports: 13 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 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