storage

package
v0.0.0-...-99b1a73 Latest Latest
Warning

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

Go to latest
Published: Nov 16, 2022 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func MakeS3Path

func MakeS3Path(bucketPrefix, user, userPath string) (string, error)

MakeS3Path internal method validates inputs, and constructs a bucket path from the given bucket prefix, user id, and userPath

func SetupHttpListeners

func SetupHttpListeners(mgr Manager) error

SetupHttpListeners setup endpoints with the http engine

Types

type ApiRequest

type ApiRequest struct {
	Verb      string
	Workspace string
	Key       string
	Cx        *SessionContext
}

func NewApiRequest

func NewApiRequest(url *url.URL, method string, remoteUser string) (*ApiRequest, error)

NewApiRequest extracts the api request parameters from the URL path and the remote user header. urlPath should be $verb/$workspace/$key, remoteUser should be set by the API gateway after verfying authentication and authorization

func (*ApiRequest) HandleApiRequest

func (self *ApiRequest) HandleApiRequest(mgr Manager) *ApiResult

type ApiResult

type ApiResult struct {
	Version int
	Method  string
	Result  string
	Data    ApiResultData
}

type ApiResultData

type ApiResultData interface{}

type Config

type Config struct {
	Bucket       string `json:"bucket"`
	BucketPrefix string `json:"bucketprefix"`
	LogLevel     string `json:"loglevel"`
}

Config for constructing an AppContext

func LoadConfig

func LoadConfig(configFilePath string) (config *Config, err error)

LoadConfig from a json file

type ListResult

type ListResult struct {
	Workspace string
	Prefix    string
	Objects   []ObjectInfo
	Prefixes  []string
}

type Manager

type Manager interface {
	List(cx *SessionContext, workspaceIn string, prefix string, page string) (*ListResult, error)
	UploadUrl(cx *SessionContext, workspaceIn string, key string) (string, error)
	DownloadUrl(cx *SessionContext, workspaceIn string, key string) (string, error)
	DeleteObject(cx *SessionContext, workspaceIn string, key string) error
}

func NewManager

func NewManager(config *Config) (mgr Manager, err error)

NewManager makes a new manager with the given configuration

type ObjectInfo

type ObjectInfo struct {
	Workspace    string
	WorkspaceKey string
	SizeBytes    int64
	LastModified time.Time
}

type SessionContext

type SessionContext struct {
	User string
}

AppContext runtime context

func NewSessionContext

func NewSessionContext(user string) (cx *SessionContext)

type SimpleManager

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

func (*SimpleManager) DeleteObject

func (self *SimpleManager) DeleteObject(cx *SessionContext, workspaceIn string, key string) error

DownloadUrl generates a presigned download url Use the range HTTP header to download range of bytes -

https://docs.aws.amazon.com/AmazonS3/latest/dev/GettingObjectsUsingAPIs.html

func (*SimpleManager) DownloadUrl

func (self *SimpleManager) DownloadUrl(cx *SessionContext, workspaceIn string, key string) (string, error)

DownloadUrl generates a presigned download url Use the range HTTP header to download range of bytes -

https://docs.aws.amazon.com/AmazonS3/latest/dev/GettingObjectsUsingAPIs.html

func (*SimpleManager) List

func (self *SimpleManager) List(cx *SessionContext, workspaceIn string, prefix string, page string) (*ListResult, error)

List the prefixes and objects under a given workspace and prefix. Currently no paging support - limit to 1000. Currently only support user workspace.

func (*SimpleManager) UploadUrl

func (self *SimpleManager) UploadUrl(cx *SessionContext, workspaceIn string, key string) (string, error)

UploadUrl generates a presigned upload url TODO - support multipart upload

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL
JackTT - Gopher 🇻🇳