kk_file

package
v0.0.0-...-cfc9456 Latest Latest
Warning

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

Go to latest
Published: Apr 26, 2024 License: BSD-3-Clause Imports: 5 Imported by: 0

Documentation

Index

Constants

View Source
const (
	TypeImage = 1
)

Variables

View Source
var (
	Jpeg = FileType{
		ContentType: "image/jpeg",
		Suffix:      ".jpg",
	}

	Avif = FileType{
		ContentType: "image/avif",
		Suffix:      ".avif",
	}

	Gif = FileType{
		ContentType: "image/gif",
		Suffix:      ".gif",
	}

	Png = FileType{
		ContentType: "image/png",
		Suffix:      ".png",
	}
	Heic = FileType{
		ContentType: "image/heic",
		Suffix:      ".heic",
	}
)

Functions

func ConvertFileSizeMB

func ConvertFileSizeMB(size int64) float64

ConvertFileSizeMB 转换文件大小B->MB

func DetectTypeByBytes

func DetectTypeByBytes(bytes []byte) string

DetectTypeByBytes 通过文件头判断图片类型

func DetectTypeByFile

func DetectTypeByFile[T *os.File | *multipart.FileHeader](stage *kk_stage.Stage, file T) string

DetectTypeByFile 通过文件头判断图片类型 支持os.File和multipart.FileHeader 二选一

Types

type FileSize

type FileSize int
const (
	KB FileSize = 1 << 10 // 1KB
	MB FileSize = 1 << 20 // 1MB
	GB FileSize = 1 << 30 // 1GB
)

func (FileSize) Int

func (fs FileSize) Int() int

func (FileSize) Int64

func (fs FileSize) Int64() int64

type FileType

type FileType struct {
	ContentType string
	Suffix      string
}

func New

func New(contentType string) FileType

Jump to

Keyboard shortcuts

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