uploader

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Sep 1, 2019 License: MIT Imports: 19 Imported by: 0

Documentation

Overview

Copyright 2019 Axetroy. All rights reserved. MIT license.

Copyright 2019 Axetroy. All rights reserved. MIT license.

Copyright 2019 Axetroy. All rights reserved. MIT license.

Copyright 2019 Axetroy. All rights reserved. MIT license.

Index

Constants

This section is empty.

Variables

View Source
var Config = TConfig{
	Path: dotenv.Get("UPLOAD_DIR"),
	File: FileConfig{
		Path:    "file",
		MaxSize: 1024 * 1024 * 10,
	},
	Image: ImageConfig{
		Path:    "image",
		MaxSize: 1024 * 1024 * 10,
		Thumbnail: ThumbnailConfig{
			Path:      "thumbnail",
			MaxWidth:  100,
			MaxHeight: 100,
		},
		Avatar: AvatarConfig{
			Path: "avatar",
		},
	},
}

Functions

func Example

func Example(context *gin.Context)

func File

func File(context *gin.Context)

func GenerateThumbnail

func GenerateThumbnail(imagePath string) (outputPath string, err error)

* Generate thumbnail

func Image

func Image(context *gin.Context)

Types

type AvatarConfig

type AvatarConfig struct {
	Path string // 头像存储的路径
}

type FileConfig

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

type ImageConfig

type ImageConfig struct {
	Path      string          `json:"path"`      // 图片存储路径
	MaxSize   int             `json:"max_size"`  // 最大图片上传限制,单位byte
	Thumbnail ThumbnailConfig `json:"thumbnail"` // 缩略图配置
	Avatar    AvatarConfig    `json:"avatar"`    // 用户头像的配置
}

type ImageResponse

type ImageResponse struct {
	schema.FileResponse
	Thumbnail     bool   `json:"thumbnail"`      // 是否拥有缩略图
	ThumbnailPath string `json:"thumbnail_path"` // 缩略图的路径
}

type TConfig

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

type ThumbnailConfig

type ThumbnailConfig struct {
	Path      string `json:"path"`       // 缩略图存放路径
	MaxWidth  int    `json:"max_width"`  // 缩略图最大宽度
	MaxHeight int    `json:"max_height"` // 缩略图最大高度
}

Jump to

Keyboard shortcuts

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