storage

package
v0.0.0-...-327476c Latest Latest
Warning

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

Go to latest
Published: May 27, 2023 License: Apache-2.0 Imports: 16 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CreateMetadataIndex

func CreateMetadataIndex(ctx context.Context, coll *mongo.Collection) error

func MakeSymlinkQuery

func MakeSymlinkQuery(expiration, id string) string

func MakeSymlinkSignature

func MakeSymlinkSignature(expiration, id, name string) string

func NewMongoClient

func NewMongoClient(ctx context.Context, uri string) (*mongo.Client, error)

NewMongoClient creates a new mongo client using a connection uri. The caller is responsible for calling Disconnect:

client.Disconnect(ctx)

func NewS3Session

func NewS3Session(region, s3_endpoint, accessKey, secretKey string) (*session.Session, error)

Types

type FileDownloader

type FileDownloader func(file io.Writer, filename string) error

func NewS3FileDownloader

func NewS3FileDownloader(s3Sess *session.Session, bucket string) FileDownloader

type FileUploader

type FileUploader func(file io.Reader, filename string) error

func NewS3FileUploader

func NewS3FileUploader(sess *session.Session, bucket string) FileUploader

type Metadata

type Metadata struct {
	Id        string    `bson:"id"`
	FileName  string    `bson:"filename"`
	CreatedAt time.Time `bson:"createdAt"`
}

func NewMetadata

func NewMetadata(filename string) *Metadata

type MetadataClient

type MetadataClient interface {
	Create(ctx context.Context, md *Metadata) error
	GetById(ctx context.Context, id string) (*Metadata, error)
	DeleteById(ctx context.Context, id string) error
}

func NewMongoMetadataClient

func NewMongoMetadataClient(c *mongo.Client) MetadataClient

type MockMetadataClient

type MockMetadataClient struct {
	CreateFunc  func(ctx context.Context, md *Metadata) error
	GetFileById func(ctx context.Context, id string) (*Metadata, error)
}

MockMetadataClient is a mock of MetadataClient which can be used by tests.

func (*MockMetadataClient) Create

func (m *MockMetadataClient) Create(ctx context.Context, md *Metadata) error

func (*MockMetadataClient) DeleteById

func (m *MockMetadataClient) DeleteById(ctx context.Context, id string) error

func (*MockMetadataClient) GetById

func (m *MockMetadataClient) GetById(ctx context.Context, id string) (*Metadata, error)
type Symlink struct {
	Hash       string
	Expiration string
	Id         string
	Name       string
	Link       string
}

func SymlinkFromQuery

func SymlinkFromQuery(r *http.Request) *Symlink

Jump to

Keyboard shortcuts

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