fileutil

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: 11 Imported by: 0

Documentation

Index

Constants

View Source
const (
	NONE = Format(iota)
	GIF
	JPG
	PNG
	WEBP
)

Variables

View Source
var (
	ErrContentType        = errors.New("invalid-content-type")
	ErrSomethingWentWrong = errors.New(apierr.SomethingWentWrong.String())
	ErrFileSize           = errors.New("invalid-file-size")
)
View Source
var (
	ImageContentTypes = []string{"image/png", "image/jpeg", "image/gif", "image/webp"}
)

Functions

func Exist

func Exist(filePath string) bool

func FilePath

func FilePath(relativePath string) string

func PublicPath

func PublicPath(relativePath string) string

func RelativePath

func RelativePath(prePath, b58hash string, includeFile bool) string

Types

type Format

type Format int

func ContentTypeToFormat

func ContentTypeToFormat(ct string) Format

func ExtensionToFormat

func ExtensionToFormat(ext string) Format

func (*Format) DecodeMsg

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

DecodeMsg implements msgp.Decodable

func (Format) EncodeMsg

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

EncodeMsg implements msgp.Encodable

func (Format) FileExt

func (f Format) FileExt() string

func (Format) IsImage

func (f Format) IsImage() bool

func (Format) MarshalMsg

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

MarshalMsg implements msgp.Marshaler

func (Format) Msgsize

func (z Format) Msgsize() (s int)

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

func (*Format) UnmarshalMsg

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

UnmarshalMsg implements msgp.Unmarshaler

type VaidateConfig

type VaidateConfig struct {
	MaxSize      int64
	ContentTypes []string
}

func NewVaidateConfig

func NewVaidateConfig(maxSize int64, contentTypes ...string) *VaidateConfig

func (*VaidateConfig) ContentType

func (vc *VaidateConfig) ContentType(contentType string) error

func (*VaidateConfig) MpFileHeader

func (vc *VaidateConfig) MpFileHeader(fileHead *multipart.FileHeader) error

func (*VaidateConfig) Size

func (vc *VaidateConfig) Size(size int64) error

Jump to

Keyboard shortcuts

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