config

package
v0.7.0 Latest Latest
Warning

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

Go to latest
Published: Jun 19, 2020 License: MIT Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Upload = TConfig{
	Path: dotenv.GetByDefault("UPLOAD_DIR", "upload"),
	File: FileConfig{
		Path:      "file",
		MaxSize:   dotenv.GetInt64ByDefault("UPLOAD_FILE_MAX_SIZE", 1024*1024*10),
		AllowType: dotenv.GetStrArrayByDefault("UPLOAD_FILE_EXTENSION", []string{".txt", ".md"}),
	},
	Image: ImageConfig{
		Path:    "image",
		MaxSize: dotenv.GetInt64ByDefault("UPLOAD_IMAGE_MAX_SIZE", 1024*1024*10),
	},
}

Functions

func Init added in v0.4.0

func Init()

确保上传的文件目录存在

Types

type FileConfig

type FileConfig struct {
	Path      string   `json:"path"`       // 普通文件的存放目录
	MaxSize   int64    `json:"max_size"`   // 普通文件上传的限制大小,单位byte, 最大单位1GB
	AllowType []string `json:"allow_type"` // 允许上传的文件后缀名
}

type ImageConfig

type ImageConfig struct {
	Path    string `json:"path"`     // 图片存储路径
	MaxSize int64  `json:"max_size"` // 最大图片上传限制,单位byte
}

type TConfig

type TConfig struct {
	Path  string      `json:"path"`  //文件上传的根目录
	File  FileConfig  `json:"file"`  // 普通文件上传的配置
	Image ImageConfig `json:"image"` // 普通图片上传的配置
}

Jump to

Keyboard shortcuts

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