kasset

package module
v0.0.7 Latest Latest
Warning

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

Go to latest
Published: Oct 27, 2023 License: MIT Imports: 21 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	Event kaos.EventHub
	Topic string
)

Functions

func GetFileType added in v0.0.2

func GetFileType(buffer []byte) (string, string, error)

func GetTenantDBFromContext added in v0.0.7

func GetTenantDBFromContext(ctx *kaos.Context) *datahub.Hub

func NewSimpleFS

func NewSimpleFS(basicPath string) *simpleFS

Types

type Asset

type Asset struct {
	orm.DataModelBase `json:"-" bson:"-"`
	ID                string `json:"_id" bson:"_id"`
	Title             string
	OriginalFileName  string
	NewFileName       string
	URI               string
	ContentType       string
	Size              int
	Tags              []string
	Kind              string
	RefID             string
	Data              codekit.M
}

func (*Asset) GetID

func (a *Asset) GetID(c dbflex.IConnection) ([]string, []interface{})

func (*Asset) Indexes added in v0.0.6

func (a *Asset) Indexes() []dbflex.DbIndex

func (*Asset) PreSave

func (a *Asset) PreSave(c dbflex.IConnection) error

func (*Asset) SetID

func (a *Asset) SetID(keys ...interface{})

func (*Asset) TableName

func (a *Asset) TableName() string

type AssetAPIEngine

type AssetAPIEngine struct {
}

func (*AssetAPIEngine) FindByRefID

func (ae *AssetAPIEngine) FindByRefID(ctx *kaos.Context, req *ReferenceRequest) ([]*Asset, error)

func (*AssetAPIEngine) MakeRef

func (ae *AssetAPIEngine) MakeRef(ctx *kaos.Context, req *AssetReference) (string, error)

type AssetData

type AssetData struct {
	Asset   *Asset
	Content []byte
}

func NewAssetData

func NewAssetData() *AssetData

type AssetDataBase64 added in v0.0.6

type AssetDataBase64 struct {
	Asset   *Asset
	Content string
}

type AssetEngine

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

func NewAssetEngine

func NewAssetEngine(fs AssetFS, topicPrefix string) *AssetEngine

func (*AssetEngine) Delete

func (ae *AssetEngine) Delete(ctx *kaos.Context, id string) (int, error)

func (*AssetEngine) Read

func (a *AssetEngine) Read(ctx *kaos.Context, id string) (*Asset, error)

func (*AssetEngine) SaveAttr

func (ae *AssetEngine) SaveAttr(ctx *kaos.Context, req *SaveAttrRequest) (string, error)

func (*AssetEngine) View

func (ae *AssetEngine) View(ctx *kaos.Context, assetid string) ([]byte, error)

func (*AssetEngine) Write

func (a *AssetEngine) Write(ctx *kaos.Context, attachReq *AssetData) (*Asset, error)

func (*AssetEngine) WriteWithContent added in v0.0.7

func (a *AssetEngine) WriteWithContent(ctx *kaos.Context, attachReq *AssetDataBase64) (*Asset, error)

type AssetFS

type AssetFS interface {
	Save(string, []byte) error
	Read(string) ([]byte, error)
	Delete(string) error
}

type AssetReference

type AssetReference struct {
	orm.DataModelBase `json:"-" bson:"-"`
	ID                string `json:"_id" bson:"_id"`
	AssetID           string
	RefType           string
	RefID             string
	Feature           string
}

func (*AssetReference) GetID

func (ar *AssetReference) GetID(_ dbflex.IConnection) ([]string, []interface{})

func (*AssetReference) Indexes added in v0.0.6

func (ar *AssetReference) Indexes() []dbflex.DbIndex

func (*AssetReference) SetID

func (ar *AssetReference) SetID(keys ...interface{})

func (*AssetReference) TableName

func (ar *AssetReference) TableName() string

type ReferenceRequest

type ReferenceRequest struct {
	RefType string
	RefID   string
}

type S3Asset

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

func NewS3 added in v0.0.2

func NewS3(key, secret, token, bucket string) (*S3Asset, error)

func NewS3WithConfig added in v0.0.6

func NewS3WithConfig(bucket string, config *aws.Config) (*S3Asset, error)

func (*S3Asset) Delete

func (sfs *S3Asset) Delete(name string) error

func (*S3Asset) Read

func (sfs *S3Asset) Read(name string) ([]byte, error)

func (*S3Asset) Save

func (sfs *S3Asset) Save(name string, bs []byte) error

type SaveAttrRequest

type SaveAttrRequest struct {
	ID   string                 `json:"_id"`
	Data map[string]interface{} `json:"data"`
}

Jump to

Keyboard shortcuts

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