upload

package
v1.3.2 Latest Latest
Warning

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

Go to latest
Published: May 12, 2023 License: MIT Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrorUploadType = errors.New("Type of Upload not allowed")
	ErrorFileType   = errors.New("Type of file not allowed")
	ErrorSmallSize  = errors.New("File is too small")
	ErrorBigSize    = errors.New("File is too big")
)

Functions

This section is empty.

Types

type Config

type Config struct {
	StaticDir      string
	MinSize        int64
	MaxSize        int64
	MaxWidthHeight int
	SmallMaxWH     int
	AlbumID        int64
	LastSource     string
	UploadType     int
	W              int
	H              int
}

type FileInfo

type FileInfo struct {
	Config        *Config     `json:"-"`
	Image         image.Image `json:"-"`
	Size          int64       `json:"-"`
	FileType      string      `json:"-"`
	Name          string      `json:"name"`
	URL           string      `json:"url"`
	ScreenShotURL string      `json:"screen_shot_url"`
	DialogID      string      `json:"dialog_id"`
	Success       int         `json:"success"`
	Message       string      `json:"message"`
}

func NewFileInfo

func NewFileInfo(file io.Reader, fileName string, opt ...*Config) (*FileInfo, error)

func (*FileInfo) ChangeToSmall

func (f *FileInfo) ChangeToSmall(path string) string

func (*FileInfo) CheckSource

func (f *FileInfo) CheckSource() bool

func (*FileInfo) CreatePicClip

func (f *FileInfo) CreatePicClip(path string, w, h, q int) error

* 图片裁剪 * 入参:1、file,2、输出路径,3、原图width,4、原图height,5、精度 * 规则:照片生成缩略图尺寸为w * h,先进行缩小,再进行平均裁剪 * * 返回:error

func (*FileInfo) CreatePicScale

func (f *FileInfo) CreatePicScale(path string, w, h, q int) error

* 缩略图生成 * 入参:1、file,2、输出路径,3、输出width,4、输出height,5、精度 * 规则: width,height是想要生成的尺寸 * * 返回:error

func (*FileInfo) GetFrame

func (f *FileInfo) GetFrame(mediaPath string) (string, error)

func (*FileInfo) JoinInfo

func (f *FileInfo) JoinInfo() (path string)

func (*FileInfo) ParseMediaExt

func (f *FileInfo) ParseMediaExt(fileName string)

func (*FileInfo) RemoveLastSource

func (f *FileInfo) RemoveLastSource(lastSrc string, small ...bool)

func (*FileInfo) RetMaxWH

func (f *FileInfo) RetMaxWH(max int) (int, int)

func (*FileInfo) RetRealWHEXT

func (f *FileInfo) RetRealWHEXT() (int, int)

func (*FileInfo) SaveImage

func (f *FileInfo) SaveImage(path string) (err error)

func (*FileInfo) ValidateSize

func (f *FileInfo) ValidateSize() (err error)

func (*FileInfo) ValidateType

func (f *FileInfo) ValidateType() (err error)

type Sizer

type Sizer interface {
	Size() int64
}

Jump to

Keyboard shortcuts

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