fs

package
v0.0.0-...-2189692 Latest Latest
Warning

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

Go to latest
Published: Jun 25, 2021 License: MIT Imports: 13 Imported by: 0

Documentation

Overview

inspiring from https://www.youtube.com/watch?v=1B71SL6Y0kA

Index

Constants

This section is empty.

Variables

View Source
var FileTypeMap = map[string]FileType{
	".txt": Txt,
	".doc": Doc,
}

Functions

func CheckExist

func CheckExist(src string) bool

func CheckImage

func CheckImage(src string) error

func CheckImageExt

func CheckImageExt(fileName string, uploadAllowExt []string) bool

func CheckImageSize

func CheckImageSize(f multipart.File, uploadMaxSize int) bool

func CheckNotExist

func CheckNotExist(src string) bool

func CheckPermission

func CheckPermission(src string) bool

func CopyFile

func CopyFile(src, dst string) error

CopyFile : General Approach

func FindFile

func FindFile(path string) (string, error)

path和filepath两个包,filepath文件专用

func FindFiles

func FindFiles(path string, deep int8, num int) ([]string, error)

func FindFiles2

func FindFiles2(path string, deep int8, num int) ([]string, error)

path和filepath两个包,filepath文件专用

func GetExt

func GetExt(file *multipart.FileHeader) (string, error)

func GetImageFullPath

func GetImageFullPath(uploadPath, runtimeRootPath string) string

func GetImageFullUrl

func GetImageFullUrl(uploadPath, name string) string

func GetImageName

func GetImageName(name string) string

func GetLogFilePath

func GetLogFilePath(RuntimeRootPath, LogSavePath string) string

func GetSize

func GetSize(f multipart.File) int

func IsNotExistMkdir

func IsNotExistMkdir(src string) error

func Mkdir

func Mkdir(src string) error

func MustOpen

func MustOpen(fileName, filePath string) (*os.File, error)

func Open

func Open(name string, flag int, perm os.FileMode) (*os.File, error)

func OpenLogFile

func OpenLogFile(fileName, filePath string) (*os.File, error)

func SafeCopyFile

func SafeCopyFile(src, dst string) error

SafeCopyFile : Error handling by abstraction

Types

type Dir

type Dir string

func (Dir) Open

func (d Dir) Open(name string) (*os.File, error)

type File

type File struct {
	ID           uint64 `gorm:"primary_key" json:"id"`
	FileName     string `gorm:"type:varchar(100);not null" json:"file_name"`
	OriginalName string `gorm:"type:varchar(100);not null" json:"original_name"`
	URL          string `json:"url"`
	MD5          string `gorm:"type:varchar(32)" json:"md5"`
	Mime         string `json:"mime"`
	Size         uint64 `json:"size"`
}

type FileType

type FileType int
const (
	Unknown FileType = iota
	Txt
	Doc
	Docx
	Xls
	Xlsx
)

type SafeCopy

type SafeCopy struct {
	// contains filtered or unexported fields
}

func (*SafeCopy) Close

func (c *SafeCopy) Close()

func (*SafeCopy) Copy

func (c *SafeCopy) Copy()

func (*SafeCopy) Create

func (c *SafeCopy) Create(dst string)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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