file

package
v0.0.0-...-96e820d Latest Latest
Warning

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

Go to latest
Published: Aug 19, 2018 License: MIT Imports: 21 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func PathExists

func PathExists(path string) (bool, error)

判断目录或文件是已存在

func TokeMake

func TokeMake(maps map[string]interface{}) (string, error)

令牌生成 @maps 令牌数组

func TokenDeCode

func TokenDeCode(str string) (map[string]interface{}, error)

令牌解密 @str 加密的字符串

Types

type PutRet

type PutRet struct {
	Hash string `json:"hash"`
	Key  string `json:"key"`
}

构造返回值字段

type QiNiu

type QiNiu struct {
	Config *conf.Upload `json:"-"`
}

七牛云存储

func NewQiNiu

func NewQiNiu() *QiNiu

初始化

func (*QiNiu) GetToken

func (t *QiNiu) GetToken() string

获取

func (*QiNiu) SetQiNiuConfig

func (t *QiNiu) SetQiNiuConfig() (bool, error)

七牛配置读取

func (*QiNiu) Upload

func (t *QiNiu) Upload(file multipart.File, UploadFile *UploadFile) (interface{}, error)

上传

type Size

type Size interface {
	Size() int64
}

获取文件大小的接口

type Stat

type Stat interface {
	Stat() (os.FileInfo, error)
}

获取文件信息的接口

type UploadFile

type UploadFile struct {
	NameOriginal string             `json:"name_original" name:"保存的文件名"`
	Name         string             `json:"name"  name:"原文件名"`
	Path         string             `json:"path"  name:"文件路径"`
	Size         int                `json:"size"  name:"文件大小"`
	Ext          string             `json:"ext"  name:"文件后缀"`
	Md5          string             `json:"md5"  name:"md5"`
	Http         string             `json:"http"  name:"图片http地址"`
	AttachmentId int                `json:"attachment_id"  name:"attachment_id"`
	Id           int                `json:"attachment_id"  name:"id"`
	Url          string             `json:"url"  name:"完整地址"`
	Config       *conf.Upload       `json:"-"`
	Attachment   *models.Attachment `json:"-"`
}

上传成功后返回结构体

func NewUploadFile

func NewUploadFile() *UploadFile

func Upload

func Upload(field string, r *http.Request, maps map[string]interface{}) (*UploadFile, error)

上传 @field 上传表单名称 @r Request @map 配置数组map

func (*UploadFile) Check

func (c *UploadFile) Check() (bool, error)

审核

func (*UploadFile) GetLocalTmpPath

func (c *UploadFile) GetLocalTmpPath() string

本地临时文件路径

func (*UploadFile) LocalSaveFile

func (c *UploadFile) LocalSaveFile(file multipart.File, path, file_name string) (bool, error)

本地保存

func (*UploadFile) LocalTmpFileRemove

func (c *UploadFile) LocalTmpFileRemove() error

本地临时文件

func (*UploadFile) SaveDataBase

func (c *UploadFile) SaveDataBase(maps map[string]interface{})

保存到数据库

func (*UploadFile) SetConfig

func (c *UploadFile) SetConfig(mod string) (bool, error)

设置配置

func (*UploadFile) SetUploadFileData

func (c *UploadFile) SetUploadFileData(upload_type string, file multipart.File, header *multipart.FileHeader) (bool, error)

文件基本数据填充 @upload_type 上传配置

Jump to

Keyboard shortcuts

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