Documentation
¶
Index ¶
- Constants
- type Config
- type FileItem
- type List
- type ListFileItem
- type ListInterface
- type ListParams
- type ResFileInfo
- type ResFileInfoWithState
- type ResFilesInfoWithStates
- type Service
- func (serv *Service) CatchImage(r *http.Request) (listRes *ResFilesInfoWithStates, err error)
- func (serv *Service) Config() (cnf *Config)
- func (serv *Service) ListImage(listFileItem *ListFileItem, start int, size int)
- func (serv *Service) Listfile(listFileItem *ListFileItem, start int, size int)
- func (serv *Service) UploadFile(r *http.Request) (res *ResFileInfoWithState, err error)
- func (serv *Service) UploadScrawl(r *http.Request) (res *ResFileInfoWithState, err error)
- func (serv *Service) UploadVideo(r *http.Request) (res *ResFileInfoWithState, err error)
- func (serv *Service) Uploadimage(r *http.Request) (res *ResFileInfoWithState, err error)
- type Uploader
- func (up *Uploader) SaveRemote(remoteUrl string) (fileInfo *ResFileInfo, err error)
- func (up *Uploader) SetParams(params *UploaderParams) (err error)
- func (up *Uploader) SetRootPath(path string) error
- func (up *Uploader) SetStorage(storageObj storage.BaseInterface) (err error)
- func (up *Uploader) UpBase64(fileName, base64data string) (fileInfo *ResFileInfo, err error)
- func (up *Uploader) UpFile(file multipart.File, fileHeader *multipart.FileHeader) (fileInfo *ResFileInfo, err error)
- type UploaderInterface
- type UploaderParams
Constants ¶
View Source
const ( SUCCESS string = "SUCCESS" //上传成功标记,在UEditor中内不可改变,否则flash判断会出错 ERROR string = "ERROR" NO_MATCH_FILE string = "no match file" )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Config ¶
type Config struct {
ImageActionName string `json:"imageActionName"`
ImageFieldName string `json:"imageFieldName"`
ImageMaxSize int `json:"imageMaxSize"`
ImageAllowFiles []string `json:"imageAllowFiles"`
ImageCompressEnable bool `json:"imageCompressEnable"`
ImageCompressBorder int `json:"imageCompressBorder"`
ImageInsertAlign string `json:"imageInsertAlign"`
ImageURLPrefix string `json:"imageUrlPrefix"`
ImagePathFormat string `json:"imagePathFormat"`
ScrawlActionName string `json:"scrawlActionName"`
ScrawlFieldName string `json:"scrawlFieldName"`
ScrawlPathFormat string `json:"scrawlPathFormat"`
ScrawlMaxSize int `json:"scrawlMaxSize"`
ScrawlURLPrefix string `json:"scrawlUrlPrefix"`
ScrawlInsertAlign string `json:"scrawlInsertAlign"`
SnapscreenActionName string `json:"snapscreenActionName"`
SnapscreenPathFormat string `json:"snapscreenPathFormat"`
SnapscreenURLPrefix string `json:"snapscreenUrlPrefix"`
SnapscreenInsertAlign string `json:"snapscreenInsertAlign"`
CatcherLocalDomain []string `json:"catcherLocalDomain"`
CatcherActionName string `json:"catcherActionName"`
CatcherFieldName string `json:"catcherFieldName"`
CatcherPathFormat string `json:"catcherPathFormat"`
CatcherURLPrefix string `json:"catcherUrlPrefix"`
CatcherMaxSize int `json:"catcherMaxSize"`
CatcherAllowFiles []string `json:"catcherAllowFiles"`
VideoActionName string `json:"videoActionName"`
VideoFieldName string `json:"videoFieldName"`
VideoPathFormat string `json:"videoPathFormat"`
VideoURLPrefix string `json:"videoUrlPrefix"`
VideoMaxSize int `json:"videoMaxSize"`
VideoAllowFiles []string `json:"videoAllowFiles"`
FileActionName string `json:"fileActionName"`
FileFieldName string `json:"fileFieldName"`
FilePathFormat string `json:"filePathFormat"`
FileURLPrefix string `json:"fileUrlPrefix"`
FileMaxSize int `json:"fileMaxSize"`
FileAllowFiles []string `json:"fileAllowFiles"`
ImageManagerActionName string `json:"imageManagerActionName"`
ImageManagerListPath string `json:"imageManagerListPath"`
ImageManagerListSize int `json:"imageManagerListSize"`
ImageManagerURLPrefix string `json:"imageManagerUrlPrefix"`
ImageManagerInsertAlign string `json:"imageManagerInsertAlign"`
ImageManagerAllowFiles []string `json:"imageManagerAllowFiles"`
FileManagerActionName string `json:"fileManagerActionName"`
FileManagerListPath string `json:"fileManagerListPath"`
FileManagerURLPrefix string `json:"fileManagerUrlPrefix"`
FileManagerListSize int `json:"fileManagerListSize"`
FileManagerAllowFiles []string `json:"fileManagerAllowFiles"`
}
var GloabConfig *Config
type List ¶
type List struct {
RootPath string // 项目根目录
Params *ListParams // 参数
}
func (*List) GetFileList ¶
* 获取资源列表
func (*List) SetParams ¶
func (l *List) SetParams(params *ListParams) error
func (*List) SetRootPath ¶
type ListFileItem ¶
type ListInterface ¶
type ListParams ¶
type ResFileInfo ¶
type ResFileInfoWithState ¶
type ResFileInfoWithState struct {
State string `json:"state"`
ResFileInfo
}
type ResFilesInfoWithStates ¶
type ResFilesInfoWithStates struct {
State string `json:"state"`
List []*ResFileInfo `json:"list"`
}
type Service ¶
type Service struct {
// contains filtered or unexported fields
}
func NewService ¶
func NewService(uploaderObj UploaderInterface, listObj ListInterface, rootPath string, configFilePath string) (serv *Service, err error)
func NewServiceWithStorageObj ¶
func NewServiceWithStorageObj(storageObj storage.BaseInterface, rootPath string, configFilePath string) (serv *Service, err error)
* 创建service,并制定存储实例
func (*Service) CatchImage ¶
func (serv *Service) CatchImage(r *http.Request) (listRes *ResFilesInfoWithStates, err error)
* 从远程拉取图片
func (*Service) ListImage ¶
func (serv *Service) ListImage(listFileItem *ListFileItem, start int, size int)
* 获取图片列表
func (*Service) Listfile ¶
func (serv *Service) Listfile(listFileItem *ListFileItem, start int, size int)
* 获取文件列表
func (*Service) UploadFile ¶
func (serv *Service) UploadFile(r *http.Request) (res *ResFileInfoWithState, err error)
* 上传文件
func (*Service) UploadScrawl ¶
func (serv *Service) UploadScrawl(r *http.Request) (res *ResFileInfoWithState, err error)
* 上传涂鸦
func (*Service) UploadVideo ¶
func (serv *Service) UploadVideo(r *http.Request) (res *ResFileInfoWithState, err error)
* 上传视频
func (*Service) Uploadimage ¶
func (serv *Service) Uploadimage(r *http.Request) (res *ResFileInfoWithState, err error)
* 上传图片
type Uploader ¶
type Uploader struct {
RootPath string // 项目根目录
Storage storage.BaseInterface // 文件、图片保存的方法
// contains filtered or unexported fields
}
func (*Uploader) SaveRemote ¶
func (up *Uploader) SaveRemote(remoteUrl string) (fileInfo *ResFileInfo, err error)
* 拉取远程文件并保存
func (*Uploader) SetParams ¶
func (up *Uploader) SetParams(params *UploaderParams) (err error)
func (*Uploader) SetRootPath ¶
func (*Uploader) SetStorage ¶
func (up *Uploader) SetStorage(storageObj storage.BaseInterface) (err error)
* 设置文件存储对象
func (*Uploader) UpBase64 ¶
func (up *Uploader) UpBase64(fileName, base64data string) (fileInfo *ResFileInfo, err error)
* 上传base64数据文件
func (*Uploader) UpFile ¶
func (up *Uploader) UpFile(file multipart.File, fileHeader *multipart.FileHeader) (fileInfo *ResFileInfo, err error)
* 上传文件
type UploaderInterface ¶
type UploaderInterface interface {
UpFile(file multipart.File, handle *multipart.FileHeader) (fileInfo *ResFileInfo, err error) //上传文件的方法
UpBase64(fileName, base64data string) (fileInfo *ResFileInfo, err error) //处理base64编码的图片上传
SaveRemote(remoteUrl string) (fileInfo *ResFileInfo, err error) // 拉取远程图片
SetParams(params *UploaderParams) error // 设置参数信息
SetRootPath(path string) error // 设置根目录
SetStorage(storageObj storage.BaseInterface) error // 设置文件存储的操作实例
}
Click to show internal directories.
Click to hide internal directories.