media

package
v0.0.0-...-1ad4281 Latest Latest
Warning

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

Go to latest
Published: Nov 11, 2022 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

View Source
const (
	MaxImageSize int64 = 10 * 1024 * 1024 // 10Mb
)
View Source
const (
	SubPath = "posts/images"
)

Variables

This section is empty.

Functions

func Insert

func Insert(postId int64, alt string, fileId int64) error

func InsertFile

func InsertFile(media *Media, hash string, newHash string) (int64, error)

func TransformAndSave

func TransformAndSave(postID int64, imageMPH *multipart.FileHeader, alt string) error

func ValidateMpFileHeader

func ValidateMpFileHeader(fileHead *multipart.FileHeader) error

ValidateMpFileHeader multipart.FileHeader

Types

type Media

type Media struct {
	FileType fileutil.Format `msg:"fileType" json:"fileType,omitempty"`
	Meta     *Meta           `msg:"meta" json:"meta"`
	Url      string          `msg:"url" json:"url"`
}

func Get

func Get(postID int64) ([]*Media, error)

func New

func New() *Media

func (*Media) DecodeMsg

func (z *Media) DecodeMsg(dc *msgp.Reader) (err error)

DecodeMsg implements msgp.Decodable

func (*Media) EncodeMsg

func (z *Media) EncodeMsg(en *msgp.Writer) (err error)

EncodeMsg implements msgp.Encodable

func (*Media) MarshalMsg

func (z *Media) MarshalMsg(b []byte) (o []byte, err error)

MarshalMsg implements msgp.Marshaler

func (*Media) Msgsize

func (z *Media) Msgsize() (s int)

Msgsize returns an upper bound estimate of the number of bytes occupied by the serialized message

func (*Media) UnmarshalMsg

func (z *Media) UnmarshalMsg(bts []byte) (o []byte, err error)

UnmarshalMsg implements msgp.Unmarshaler

type Meta

type Meta struct {
	Alt    string `msg:"alt" json:"alt"`
	Width  int64  `msg:"width" json:"width"`
	Height int64  `msg:"height" json:"height"`
}

func (*Meta) DecodeMsg

func (z *Meta) DecodeMsg(dc *msgp.Reader) (err error)

DecodeMsg implements msgp.Decodable

func (Meta) EncodeMsg

func (z Meta) EncodeMsg(en *msgp.Writer) (err error)

EncodeMsg implements msgp.Encodable

func (Meta) MarshalMsg

func (z Meta) MarshalMsg(b []byte) (o []byte, err error)

MarshalMsg implements msgp.Marshaler

func (Meta) Msgsize

func (z Meta) Msgsize() (s int)

Msgsize returns an upper bound estimate of the number of bytes occupied by the serialized message

func (*Meta) UnmarshalMsg

func (z *Meta) UnmarshalMsg(bts []byte) (o []byte, err error)

UnmarshalMsg implements msgp.Unmarshaler

Jump to

Keyboard shortcuts

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