storage

package
v1.1.1 Latest Latest
Warning

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

Go to latest
Published: Oct 14, 2024 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

Functions

This section is empty.

Types

type Bucket

type Bucket interface {
	// Allow requests the given permissions to the bucket.
	Allow(permission BucketPermission, permissions ...BucketPermission) *BucketClient

	// On registers a handler for a specific event type on the bucket.
	// Valid function signatures for handler are:
	//
	//	func()
	//	func() error
	//	func(*storage.Ctx)
	//	func(*storage.Ctx) error
	//	Handler[storage.Ctx]
	On(eventType EventType, notificationPrefixFilter string, handler interface{})
}

func NewBucket

func NewBucket(name string) Bucket

NewBucket - Create a new Bucket resource

type BucketClient

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

func NewBucketClient

func NewBucketClient(name string) (*BucketClient, error)

func (*BucketClient) Delete

func (o *BucketClient) Delete(ctx context.Context, key string) error

func (*BucketClient) DownloadUrl

func (o *BucketClient) DownloadUrl(ctx context.Context, key string, opts ...PresignUrlOption) (string, error)

func (*BucketClient) ListFiles

func (b *BucketClient) ListFiles(ctx context.Context) ([]string, error)

func (*BucketClient) Name

func (b *BucketClient) Name() string

func (*BucketClient) Read

func (o *BucketClient) Read(ctx context.Context, key string) ([]byte, error)

func (*BucketClient) UploadUrl

func (o *BucketClient) UploadUrl(ctx context.Context, key string, opts ...PresignUrlOption) (string, error)

func (*BucketClient) Write

func (o *BucketClient) Write(ctx context.Context, key string, content []byte) error

type BucketClientIface

type BucketClientIface interface {
	// Name - Get the name of the bucket
	Name() string
	// ListFiles - List the files in the bucket
	ListFiles(ctx context.Context) ([]string, error)
	// Read - Read this object
	Read(ctx context.Context, key string) ([]byte, error)
	// Write - Write this object
	Write(ctx context.Context, key string, data []byte) error
	// Delete - Delete this object
	Delete(ctx context.Context, key string) error
	// UploadUrl - Creates a signed Url for uploading this file reference
	UploadUrl(ctx context.Context, key string, opts ...PresignUrlOption) (string, error)
	// DownloadUrl - Creates a signed Url for downloading this file reference
	DownloadUrl(ctx context.Context, key string, opts ...PresignUrlOption) (string, error)
}

Cloud storage bucket resource for large file storage.

type BucketPermission

type BucketPermission string
const (
	BucketRead   BucketPermission = "read"
	BucketWrite  BucketPermission = "write"
	BucketDelete BucketPermission = "delete"
)

type Ctx

type Ctx struct {
	Request  Request
	Response *Response
	Extras   map[string]interface{}
	// contains filtered or unexported fields
}

func NewCtx

func NewCtx(msg *storagepb.ServerMessage) *Ctx

func (*Ctx) ToClientMessage

func (c *Ctx) ToClientMessage() *storagepb.ClientMessage

func (*Ctx) WithError

func (c *Ctx) WithError(err error)

type EventType

type EventType string
const (
	WriteNotification  EventType = "write"
	DeleteNotification EventType = "delete"
)

type FileResponse

type FileResponse struct {
	Success bool
}

type Mode

type Mode int
const (
	ModeRead Mode = iota
	ModeWrite
)

type PresignUrlOption

type PresignUrlOption func(opts *presignUrlOptions)

func WithPresignUrlExpiry

func WithPresignUrlExpiry(expiry time.Duration) PresignUrlOption

type Request

type Request interface {
	Key() string
	NotificationType() EventType
}

type Response

type Response struct {
	Success bool
}

Jump to

Keyboard shortcuts

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