storage

package
v0.20.0 Latest Latest
Warning

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

Go to latest
Published: Mar 9, 2026 License: Apache-2.0 Imports: 25 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrUnsupportedStorageProvider = errors.New("unsupported storage provider")
View Source
var Module = fx.Module(
	"vef:storage",
	fx.Provide(
		fx.Annotate(
			NewService,
			fx.OnStart(func(ctx context.Context, service storage.Service) error {
				if initializer, ok := service.(contract.Initializer); ok {
					if err := initializer.Init(ctx); err != nil {
						return fmt.Errorf("failed to initialize storage service: %w", err)
					}
				}

				return nil
			}),
		),
		fx.Annotate(
			NewResource,
			fx.ResultTags(`group:"vef:api:resources"`),
		),
		fx.Annotate(
			NewProxyMiddleware,
			fx.ResultTags(`group:"vef:app:middlewares"`),
		),
	),
)

Functions

func NewProxyMiddleware

func NewProxyMiddleware(service storage.Service) app.Middleware

func NewResource

func NewResource(service storage.Service) api.Resource

func NewService

func NewService(cfg *config.StorageConfig, appCfg *config.AppConfig) (storage.Service, error)

Types

type CopyParams

type CopyParams struct {
	api.P

	SourceKey string `json:"sourceKey" validate:"required"`
	DestKey   string `json:"destKey" validate:"required"`
}

type DeleteManyParams

type DeleteManyParams struct {
	api.P

	Keys []string `json:"keys" validate:"required,min=1"`
}

type DeleteParams

type DeleteParams struct {
	api.P

	Key string `json:"key" validate:"required"`
}

type DeleteTempParams

type DeleteTempParams struct {
	api.P

	Key string `json:"key" validate:"required"`
}

type GetPresignedURLParams

type GetPresignedURLParams struct {
	api.P

	Key     string `json:"key" validate:"required"`
	Expires int    `json:"expires"`
	Method  string `json:"method"`
}

type ListParams

type ListParams struct {
	api.P

	Prefix    string `json:"prefix"`
	Recursive bool   `json:"recursive"`
	MaxKeys   int    `json:"maxKeys"`
}

type MoveParams

type MoveParams struct {
	api.P

	SourceKey string `json:"sourceKey" validate:"required"`
	DestKey   string `json:"destKey" validate:"required"`
}

type ProxyMiddleware

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

func (*ProxyMiddleware) Apply

func (p *ProxyMiddleware) Apply(router fiber.Router)

func (*ProxyMiddleware) Name

func (*ProxyMiddleware) Name() string

func (*ProxyMiddleware) Order

func (*ProxyMiddleware) Order() int

type Resource

type Resource struct {
	api.Resource
	// contains filtered or unexported fields
}

func (*Resource) Copy

func (r *Resource) Copy(ctx fiber.Ctx, params CopyParams) error

func (*Resource) Delete

func (r *Resource) Delete(ctx fiber.Ctx, params DeleteParams) error

func (*Resource) DeleteMany

func (r *Resource) DeleteMany(ctx fiber.Ctx, params DeleteManyParams) error

func (*Resource) DeleteTemp

func (r *Resource) DeleteTemp(ctx fiber.Ctx, params DeleteTempParams) error

DeleteTemp restricts deletion to temp/ prefix to prevent accidental removal of permanent files.

func (*Resource) GetPresignedURL

func (r *Resource) GetPresignedURL(ctx fiber.Ctx, params GetPresignedURLParams) error

func (*Resource) List

func (r *Resource) List(ctx fiber.Ctx, params ListParams) error

func (*Resource) Move

func (r *Resource) Move(ctx fiber.Ctx, params MoveParams) error

func (*Resource) Stat

func (r *Resource) Stat(ctx fiber.Ctx, params StatParams) error

func (*Resource) Upload

func (r *Resource) Upload(ctx fiber.Ctx, params UploadParams) error

Upload generates date-partitioned keys (temp/YYYY/MM/DD/{uuid}{ext}) to organize uploads and avoid conflicts.

type StatParams

type StatParams struct {
	api.P

	Key string `json:"key" validate:"required"`
}

type UploadParams

type UploadParams struct {
	api.P

	File *multipart.FileHeader

	ContentType string            `json:"contentType"`
	Metadata    map[string]string `json:"metadata"`
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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