filepool

package module
v0.0.0-...-d2ae02e Latest Latest
Warning

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

Go to latest
Published: Nov 1, 2017 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrRequestDataType   error = errors.New("Request data field type error")
	ErrUploadFileSize    error = errors.New("Upload File size error")
	ErrRequestRestMethod error = errors.New("RESTful method error")
	ErrImageType         error = errors.New("Type of file is not image")
	ErrPermission        error = errors.New("error Permission")
)

Functions

func DetectContentType

func DetectContentType(f multipart.File) (t string, err error)

判断文件类型,检测前512字节数据,如果不能识别,返回"application/octet-stream"

func DetectImageType

func DetectImageType(f multipart.File) (t string, err error)

判断是否图片文件

func IsImageType

func IsImageType(t string) (err error)

Types

type UploadFileMode

type UploadFileMode struct {
	File        multipart.File // 文件
	FileName    string         // 文件名
	Size        int64          // 文件大小
	Sha1        string         // sha1值
	ContentType string         // 文件类型
}

获取到的文件

func NormalToUploadFile

func NormalToUploadFile(p string, meta *UploadFileRequire) (res *UploadFileMode, err error)

普通文件转为UploadFileMode类型

func UploadFileOne

func UploadFileOne(rw http.ResponseWriter, req *http.Request, meta *UploadFileRequire) (*UploadFileMode, error)

上传一个文件

func (*UploadFileMode) Close

func (f *UploadFileMode) Close()

type UploadFileRequire

type UploadFileRequire struct {
	MaxSize      int64  // 上传文件大小限制
	FormName     string // 表格中储存file的字段名
	RequireImage bool   // 是否要求图片类型
	Rename       string // 将文件名视为
	// 更改返回格式
	FmtHandler func(resp interface{}) (newResp interface{}, err error)
}

Directories

Path Synopsis
lib
go-uuid/uuid
The uuid package generates and inspects UUIDs.
The uuid package generates and inspects UUIDs.
mapstructure
The mapstructure package exposes functionality to convert an abitrary map[string]interface{} into a native Go structure.
The mapstructure package exposes functionality to convert an abitrary map[string]interface{} into a native Go structure.
mergo
Package mergo merges same-type structs and maps by setting default values in zero-value fields.
Package mergo merges same-type structs and maps by setting default values in zero-value fields.
pbkdf2
Package pbkdf2 implements the key derivation function PBKDF2 as defined in RFC 2898 / PKCS #5 v2.0.
Package pbkdf2 implements the key derivation function PBKDF2 as defined in RFC 2898 / PKCS #5 v2.0.
resize
Package resize implements various image resizing methods.
Package resize implements various image resizing methods.
scrypt
Package scrypt implements the scrypt key derivation function as defined in Colin Percival's paper "Stronger Key Derivation via Sequential Memory-Hard Functions" (http://www.tarsnap.com/scrypt/scrypt.pdf).
Package scrypt implements the scrypt key derivation function as defined in Colin Percival's paper "Stronger Key Derivation via Sequential Memory-Hard Functions" (http://www.tarsnap.com/scrypt/scrypt.pdf).

Jump to

Keyboard shortcuts

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