filestore

package
v0.0.0-...-04bf11e Latest Latest
Warning

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

Go to latest
Published: Dec 17, 2017 License: Apache-2.0 Imports: 17 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Zip

func Zip(input *tar.Reader, output io.Writer) error

Zip reads all files from a tar reader and compresses them to a zip byte array.

Types

type Local

type Local struct {
	UploadDirectory string
	SourceDirectory string
	// contains filtered or unexported fields
}

Local stores files locally on disk

func NewLocal

func NewLocal(uploadDir, sourceDir string) (*Local, error)

NewLocal creates a local filestore and starts listening on a port assigned by the operating system. The files are stored on local disk on the server. The uploadDir is used for storing uploads, files are moved to the sourceDir when persisted. The directories are created if they don't already exist.

func (*Local) GetFile

func (l *Local) GetFile(name string) (*os.File, error)

GetFile returns a source file from the local filestore.

func (*Local) NewUploadURL

func (l *Local) NewUploadURL(name string) (string, error)

NewUploadURL creates a new upload url that the local filestore will handle.

func (*Local) Persist

func (l *Local) Persist(ctx context.Context, name string) error

Persist moves the file from the upload directory to the source directory.

func (*Local) Shutdown

func (l *Local) Shutdown() error

Shutdown gracefully closes the local filestore. New connections are not accepted after Close() and existing connections are drained before shutdown.

type S3

type S3 struct {
	Client       s3iface.S3API
	UploadBucket string
	UploadExpiry time.Duration
	SourceBucket string
}

S3 stores files in AWS S3

func NewS3

func NewS3(conf *aws.Config, uploadBucket string, uploadExpiry time.Duration, sourceBucket string) (*S3, error)

NewS3 creates a new S3 client

func (*S3) NewUploadURL

func (s *S3) NewUploadURL(name string) (string, error)

NewUploadURL generates a new presigned URL on S3 for upload. The url is signed with the credentials provided to the client. The upload expires automatically. The url points to the upload bucket, the name argument specified the file name.

func (*S3) Persist

func (s *S3) Persist(ctx context.Context, name string) error

Persist moves an uploaded file to a permanent bucket. Files that are not persisted might be cleaned up.

type SourceReader

type SourceReader interface {
	// GetFile gets a file from the filestore
	GetFile(filename string) (*os.File, error)
}

SourceReader reads source code from the filestore.

type SourceTarget

type SourceTarget interface {
	// NewUploadURL generates a new URL that the source can be uploaded to.
	NewUploadURL(name string) (string, error)
	// Persist persists an uploaded file.
	Persist(ctx context.Context, name string) error
}

SourceTarget is a target that accepts source code uploads.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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