Documentation
¶
Index ¶
- Variables
- func AddAuthToken(ctx context.Context, token string) error
- func AddTags(ctx context.Context, imageID string, tags []Tag) error
- func AddUploadingBytes(ctx context.Context, token string, bytes int64) error
- func CheckImageExists(ctx context.Context, md5 string) error
- func CheckTokenExists(ctx context.Context, token string) error
- func DeleteRichImage(ctx context.Context, imageID, token string) error
- func DeleteTagsForImage(ctx context.Context, imageID string, tags []Tag) error
- func GeneratePresignedUploadURL(ctx context.Context, mime, md5 string) (imageID, uri string, err error)
- func InsertRichImage(ctx context.Context, token, imageID, md5 string, tags []Tag, imgBytes int64) error
- func UpdateTagI18n(ctx context.Context, tags []Tag) error
- type AuthToken
- type Image
- type ImageTagRelation
- type RichImage
- type Tag
Constants ¶
This section is empty.
Variables ¶
View Source
var ( ErrNilToken = errors.New("token is nil") ErrNilUploadingSize = errors.New("uploading size is 0") )
View Source
var ( ErrNilMethodReceiver = errors.New("method receiver is nil") ErrNilImageID = errors.New("image is nil") ErrNilTag = errors.New("tag is nil") ErrUnsupportedImageType = errors.New("image type is not supported now") ErrDuplicateImage = errors.New("image is duplicated") )
View Source
var (
ErrNilMD5Sum = errors.New("md5 sum is nil. not valid")
)
View Source
var (
ErrNilTagName = errors.New("no tag name specified")
)
Functions ¶
func AddUploadingBytes ¶
func DeleteRichImage ¶ added in v0.1.2
func DeleteTagsForImage ¶
func InsertRichImage ¶
Types ¶
type AuthToken ¶
type Image ¶
type ImageTagRelation ¶
type ImageTagRelation struct { ImageID string `gorm:"column:image_id;primaryKey"` // TagName string `gorm:"column:tag_name;primaryKey"` TagID int32 `gorm:"column:tag_id;primaryKey"` }
func (*ImageTagRelation) TableName ¶
func (*ImageTagRelation) TableName() string
type RichImage ¶
type RichImage struct { CreatedAt time.Time `json:"-"` UpdatedAt time.Time `json:"-"` ImageID string `gorm:"column:image_id;primaryKey" json:"image_id"` ExternalID string `gorm:"column:external_id" json:"-"` MD5Sum string `gorm:"column:md5_sum;unique" json:"md5_sum"` // for shrinking file duplication TagIds pq.Int32Array `gorm:"column:tag_ids;type:integer[]" json:"tag_ids"` Limit int `gorm:"-"` Tags []Tag `gorm:"-"` }
func GetRandomImages ¶ added in v0.1.2
it is not efficient but suit for small dataset. for big dataset, using tablesample like below for efficiency
1) enable tsr extension: `CREATE EXTENSION tsm_system_rows` ~~2) make rich_image as a meterialed view~~ using natural join instead 3) replace below random select to this: `select * from rich_image tablesample system_rows(1);`
func GetRichImages ¶
type Tag ¶
type Tag struct { ID int32 `gorm:"column:id;primaryKey;autoIncrement"` CreatedAt time.Time `json:"-"` UpdatedAt time.Time `json:"-"` DeletedAt gorm.DeletedAt `gorm:"index" json:"-"` // Aliases pq.StringArray `gorm:"column:aliases;type:text[]" json:"aliases"` TagNameEN string `gorm:"column:tag_name_en"` TagNameCN string `gorm:"column:tag_name_cn"` TagNameJP string `gorm:"column:tag_name_jp"` }
Click to show internal directories.
Click to hide internal directories.