Documentation
¶
Index ¶
- Constants
- Variables
- func BindGin(engine *gin.Engine, c *ServiceConfig, editor *UEditor)
- func BindHTTP(mux *http.ServeMux, c *ServiceConfig, editor *UEditor) *http.ServeMux
- func BindMux(mux *mux.Router, c *ServiceConfig, editor *UEditor)
- func LowerCamelMarshal(i any) []byte
- func NewGormStorage(base string, db *gorm.DB) *gormStorage
- func NewMinioStorage(client *minio.Client) *minioStorage
- func NewSqliteStorage(base string, db *sql.DB) *sqliteStorage
- func SendJsonPResponse(w http.ResponseWriter, callback string, resp []byte)
- func SendJsonResponse(w http.ResponseWriter, resp []byte)
- type Actions
- type Config
- type FShard
- type FileInfo
- type ListResp
- type LocalStorage
- type MetaInfo
- type Resources
- type ServiceConfig
- type Storage
- type UEditor
- func (u *UEditor) GetActions() Actions
- func (u *UEditor) GetConfig() []byte
- func (u *UEditor) GetUploadFieldName() string
- func (u *UEditor) ListFiles(prefix string, offset, size int) ListResp
- func (u *UEditor) OnListFiles(offset, size int) ListResp
- func (u *UEditor) OnListImages(offset, size int) ListResp
- func (u *UEditor) OnUploadFile(h *multipart.FileHeader, f io.Reader) UploadResp
- func (u *UEditor) OnUploadImage(h *multipart.FileHeader, f io.Reader) UploadResp
- func (u *UEditor) OnUploadScrawl(h *multipart.FileHeader, f io.Reader) UploadResp
- func (u *UEditor) OnUploadVideo(h *multipart.FileHeader, f io.Reader) UploadResp
- func (u *UEditor) ReadFile(path string) (meta *MetaInfo, raw []byte, e error)
- func (u *UEditor) SaveFile(prefix string, h *multipart.FileHeader, f io.Reader) UploadResp
- func (u *UEditor) SetSrvPrefix(prefix string)
- type UploadResp
Constants ¶
View Source
const ( ImageSaveBase = "images" FileSaveBase = "files" VideoSaveBase = "videos" ScrawlSaveBase = "scrawls" )
View Source
const ( StateOK = "SUCCESS" StateFileSizeExceed = "文件大小超出限制" )
Variables ¶
Functions ¶
func BindMux ¶ added in v0.3.0
func BindMux(mux *mux.Router, c *ServiceConfig, editor *UEditor)
绑定路由到 gorrila/mux
func NewGormStorage ¶ added in v0.4.0
NewGormStorage create a *gormStorage instance which implemented Storage interface
File info is stored in given database instance, using table 'resources'
func NewMinioStorage ¶ added in v0.5.0
func NewSqliteStorage ¶ added in v0.3.0
NewSqliteStorage create a *sqliteStorage instance which implemented Storage interface
File info is stored in given sqlite database, using table 'resources'
func SendJsonPResponse ¶ added in v0.6.0
func SendJsonPResponse(w http.ResponseWriter, callback string, resp []byte)
func SendJsonResponse ¶ added in v0.3.0
func SendJsonResponse(w http.ResponseWriter, resp []byte)
Types ¶
type Actions ¶
type Actions struct {
Config string
UploadImage string
UploadFile string
UploadVideo string
UploadScrawl string
ListImages string
ListFiles string
}
ueditor 文件上传所用参数集合
type Config ¶
type Config struct {
ConfigActionName string `default:"config"`
ImageActionName string `default:"up-image"`
ImageFieldName string `default:"upfile"`
ImageMaxSize int `default:"5000000"`
ImageAllowFiles []string `default:".png|.jpg|.jpeg|.gif|.bmp"`
ImageCompressEnable bool `default:"true"`
ImageCompressBorder int `default:"1600"`
ImageInsertAlign string `default:"none"`
ImageUrlPrefix string
ScrawlActionName string `default:"up-scrawl"`
ScrawlFieldName string `default:"upfile"`
// ScrawlPathFormat string
ScrawlMaxSize int `default:"2000000"`
ScrawlUrlPrefix string
ScrawlInsertAlign string `default:"none"`
ScrawlAllowFiles []string `default:".png"`
SnapscreenActionName string `default:"up-image"`
// SnapscreenPathFormat string
SnapscreenUrlPrefix string
SnapscreenMaxSize int `default:"2000000"`
SnapscreenInsertAlign string `default:"none"`
CatcherLocalDomain []string
CatcherActionName string `default:"catch-image"`
CatcherFieldName string `default:"source"`
// CatcherPathFormat string
CatcherUrlPrefix string
CatcherMaxSize int `default:"5000000"`
CatcherAllowFiles []string `default:".png|.jpg|.jpeg|.gif|.bmp"`
VideoActionName string `default:"up-video"`
VideoFieldName string `default:"upfile"`
// VideoPathFormatstring string
VideoUrlPrefix string
VideoMaxSize int `default:"100000000"`
VideoAllowFiles []string `default:".flv|.swf|.mkv|.avi|.rm|.rmvb|.mpeg|.mpg|.ogg|.ogv|.mov|.wmv|.mp4|.webm|.mp3|.wav|.mid"`
FileActionName string `default:"up-file"`
FileFieldName string `default:"upfile"`
// FilePathFormat string
FileUrlPrefix string
FileMaxSize int `default:"50000000"`
FileAllowFiles []string `` /* 212-byte string literal not displayed */
ImageManagerActionName string `default:"list-image"`
// ImageManagerListPath string
ImageManagerListSize int `default:"20"`
ImageManagerUrlPrefix string
ImageManagerInsertAlign string `default:"none"`
ImageManagerAllowFiles []string `default:".png|.jpg|.jpeg|.gif|.bmp"`
FileManagerActionName string `default:"list-file"`
// FileManagerListPath string
FileManagerUrlPrefix string
FileManagerListSize int `default:"20"`
FileManagerAllowFiles []string `` /* 212-byte string literal not displayed */
}
前端 ueditor 配置参数,如上传文件大小限制、文件后缀等
type LocalStorage ¶
type LocalStorage struct {
Base string
}
func NewLocalStorage ¶
func NewLocalStorage(base string) *LocalStorage
NewLocalStorage create a *LocalStorage instance which implemented Storage interface
LocalStorage stores file & meta info on local file system, file & meta file are in pair
func (*LocalStorage) List ¶
func (l *LocalStorage) List(prefix string, offset, limit int) (files []FileInfo, total int)
func (*LocalStorage) Save ¶
func (l *LocalStorage) Save(prefix string, h *multipart.FileHeader, f io.Reader) (string, error)
type Resources ¶ added in v0.4.0
type Resources struct {
Category string `gorm:"uniqueIndex:ukey,size:50"`
Hash string `gorm:"uniqueIndex:ukey,size:50"`
Filename string `gorm:"size:256"`
Mimetype string `gorm:"size:50"`
Size int64
Created int64
Chunks int `gorm:"default:0"`
}
gorm 模型定义 - 表结构
type ServiceConfig ¶
type Storage ¶
type Storage interface {
Save(prefix string, h *multipart.FileHeader, f io.Reader) (path string, e error)
Read(path string) (meta *MetaInfo, content []byte, e error)
List(prefix string, offset, limit int) (files []FileInfo, total int)
}
存储接口,用于支持多种存储方式
type UEditor ¶
type UEditor struct {
// contains filtered or unexported fields
}
func (*UEditor) GetActions ¶
func (*UEditor) GetUploadFieldName ¶
func (*UEditor) OnListFiles ¶
func (*UEditor) OnListImages ¶
func (*UEditor) OnUploadFile ¶
func (u *UEditor) OnUploadFile(h *multipart.FileHeader, f io.Reader) UploadResp
func (*UEditor) OnUploadImage ¶
func (u *UEditor) OnUploadImage(h *multipart.FileHeader, f io.Reader) UploadResp
func (*UEditor) OnUploadScrawl ¶
func (u *UEditor) OnUploadScrawl(h *multipart.FileHeader, f io.Reader) UploadResp
func (*UEditor) OnUploadVideo ¶
func (u *UEditor) OnUploadVideo(h *multipart.FileHeader, f io.Reader) UploadResp
func (*UEditor) SaveFile ¶
func (u *UEditor) SaveFile(prefix string, h *multipart.FileHeader, f io.Reader) UploadResp
func (*UEditor) SetSrvPrefix ¶
Click to show internal directories.
Click to hide internal directories.