upload

package
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: 21 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	StoreDir              string        // 储存目录
	StoreDirThumbnail     string        // 缩略图储存目录
	ResizeThumbnailWidth  uint          // 缩略图宽度
	ResizeThumbnailHeight uint          // 缩略图高度
	SourceMaxWidth        uint   = 2560 // 图片素材最大宽度
	SourceMaxHeight       uint   = 2560 // 图片素材最大高度
)

储存目录

View Source
var (
	AllowCors = true
)
View Source
var (
	ErrCategory error = errors.New("Upload category is not valid")
)

Functions

func ToolFixThumbnail

func ToolFixThumbnail() (err error)

检查没有缩略图的图片文件,并生成缩略图

func ToolThumbnail

func ToolThumbnail(f multipart.File, p2 string) (err error)

将图片转缩略图

Types

type ErrorResp

type ErrorResp struct {
	Error    error  `json:"-"`
	ErrorStr string `json:"error,omitempty"`
}

func (*ErrorResp) ToJson

func (e *ErrorResp) ToJson() (s string)

json

type Picture

type Picture struct {
	OriginName          string        `json:",omitempty"` // 原文件名
	OriginWidth         int           `json:",omitempty"` // 原文件宽度
	OriginHeight        int           `json:",omitempty"` // 原文件高度
	Size                int64         `json:",omitempty"` // 文件大小
	ContentType         string        `json:",omitempty"` // 文件类型
	StoreToken          orm.Accession `json:",omitempty"` // 储存key todo: 即ID
	DeleteToken         orm.Uid       `json:",omitempty"` // 删除key
	FetchToken          string        `json:",omitempty"` // 访问key
	FetchThumbnailToken string        `json:",omitempty"` // 访问缩略图key
	Sha1                string        `json:",omitempty"` // 文件哈希
	Sha1Thumbnail       string        `json:",omitempty"` // 缩略图哈希
	CreatTime           time.Time     `json:",omitempty"` // 上传时间
	DownloadTimes       int           `json:",omitempty"` // 下载次数
	Category            string        `json:",omitempty"` // 图片类型
	// contains filtered or unexported fields
}

func (*Picture) GenDelToken

func (pic *Picture) GenDelToken() (err error)

产生删除token

func (*Picture) GenSavToken

func (pic *Picture) GenSavToken() (err error)

产生储存token

func (*Picture) Init

func (pic *Picture) Init() (err error)

***** 定义picture方法开始 ***** 初始化数据

func (*Picture) IsValid

func (pic *Picture) IsValid() (err error)

func (*Picture) Save

func (pic *Picture) Save() (err error)

保存到数据库

func (*Picture) SaveFileAndThumbnail

func (pic *Picture) SaveFileAndThumbnail(f multipart.File) (err error)

保存图片及缩略图

func (*Picture) ToJson

func (p *Picture) ToJson() (s string)

json

func (*Picture) Update

func (pic *Picture) Update() (err error)

更新到数据库

type UploadHandler

type UploadHandler struct {
	filepool.UploadFileRequire
	Category string
}

func (*UploadHandler) ServeHTTP

func (h *UploadHandler) ServeHTTP(rw http.ResponseWriter, req *http.Request)

Jump to

Keyboard shortcuts

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