storage

package
v0.19.2 Latest Latest
Warning

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

Go to latest
Published: Jan 30, 2026 License: Apache-2.0 Imports: 26 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 added in v0.10.0

func NewProxyMiddleware(service storage.Service) app.Middleware

func NewResource added in v0.8.0

func NewResource(service storage.Service) api.Resource

func NewService added in v0.8.0

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 added in v0.10.0

type DeleteTempParams struct {
	api.P

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

type GetPresignedURLParams added in v0.18.0

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 added in v0.10.0

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

func (*ProxyMiddleware) Apply added in v0.10.0

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

func (*ProxyMiddleware) Name added in v0.10.0

func (*ProxyMiddleware) Name() string

func (*ProxyMiddleware) Order added in v0.10.0

func (*ProxyMiddleware) Order() int

type Resource added in v0.8.0

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

func (*Resource) Copy added in v0.8.0

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

func (*Resource) Delete added in v0.8.0

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

func (*Resource) DeleteMany added in v0.8.0

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

func (*Resource) DeleteTemp added in v0.10.0

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 added in v0.18.0

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

func (*Resource) List added in v0.8.0

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

func (*Resource) Move added in v0.8.0

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

func (*Resource) Stat added in v0.8.0

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

func (*Resource) Upload added in v0.8.0

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
services

Jump to

Keyboard shortcuts

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