Documentation
¶
Index ¶
- Variables
- func DeleteFile(userType string, id uint64)
- func IsExistsMimeAllow(value string, array []string) bool
- func SaveFile(userType string, userId uint64, info Info) (id uint64, err error)
- type Filesystem
- func (filesystem *Filesystem) DeleteFile(filePath string) (bool, error)
- func (filesystem *Filesystem) DeleteMultipleFile(filePath []string) (bool, error)
- func (filesystem *Filesystem) DownloadNetworkFile(networkFileUrl, filePath string) error
- func (filesystem *Filesystem) EditorUpload(fileBytes []byte, allow config.FileAllow, field, filename, mime, ext string) (Info, error)
- func (filesystem *Filesystem) FullPath(filePath string) string
- func (filesystem *Filesystem) HasDir(file string) bool
- func (filesystem *Filesystem) HasFile(filePath string) bool
- func (filesystem *Filesystem) MkDir(dir string, mode os.FileMode) (bool, error)
- func (filesystem *Filesystem) NetworkFileSaveObject(networkFileUrl, filePath, mime string) (bool, error)
- func (filesystem *Filesystem) OriginalPath(filePath string) string
- func (filesystem *Filesystem) SaveFile(dstFile string, srcFile io.Reader, mimeType string) (bool, error)
- func (filesystem *Filesystem) Storage() adapter.Adapter
- func (filesystem *Filesystem) Upload(file *multipart.FileHeader, allow config.FileAllow, field string) (Info, error)
- type Info
- type Size
- type Stat
- type Uploader
Constants ¶
This section is empty.
Variables ¶
View Source
var MimeType = map[string]string{
"application/xml": "xml",
"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet": "xlsx",
"application/vnd.openxmlformats-officedocument.presentationml.presentation": "pptx",
"application/vnd.openxmlformats-officedocument.wordprocessingml.document": "docx",
"application/vnd.android.package-archive": "apk",
"application/msword": "doc",
"application/ogg": "ogg",
"application/pdf": "pdf",
"application/vnd.ms-excel": "xls",
"application/vnd.ms-powerpoint": "ppt",
"audio/mpeg": "mp2",
"audio/mp3": "mp3",
"audio/midi": "mid",
"audio/x-wav": "wav",
"audio/x-ms-wma": "wma",
"audio/x-ms-wax": "wax",
"audio/x-mpegurl": "m3u",
"image/bmp": "bmp",
"image/gif": "gif",
"image/ief": "ief",
"image/png": "png",
"image/x-rgb": "rgb",
"image/cgm": "cgm",
"image/x-icon": "ico",
"image/vnd.microsoft.icon": "ico",
"image/jp2": "jp2",
"image/jpeg": "jpg",
"image/jpe": "jpg",
"image/jpg": "jpg",
"image/webp": "webp",
"image/svg": "svg",
"image/svg+xml": "svg",
"image/tiff": "tif",
"text/csv": "csv",
"text/plain": "txt",
"text/rtf": "rtf",
"video/quicktime": "mov",
"video/mp4": "mp4",
"video/mpeg": "mpg",
"video/x-flv": "flv",
"video/x-ms-wm": "wm",
"video/x-msvideo": "avi",
"video/x-sgi-movie": "movie",
"video/3gpp": "3gp",
}
Functions ¶
func IsExistsMimeAllow ¶
IsExistsMimeAllow 判断文件MimeType
Types ¶
type Filesystem ¶
type Filesystem struct {
// contains filtered or unexported fields
}
func Instance ¶
func Instance() *Filesystem
Instance 获取单例 注意,单例仅仅为了获取filesystem及storage实例,不涉及任何上传相关的实例,如果要上传文件,还是得使用NewFilesystem生成实例
func NewFilesystem ¶
func NewFilesystem(userType string, userId uint64) (*Filesystem, error)
NewFilesystem 创建Filesystem
func (*Filesystem) DeleteFile ¶
func (filesystem *Filesystem) DeleteFile(filePath string) (bool, error)
DeleteFile 删除文件
func (*Filesystem) DeleteMultipleFile ¶
func (filesystem *Filesystem) DeleteMultipleFile(filePath []string) (bool, error)
DeleteMultipleFile 删除多个文件
func (*Filesystem) DownloadNetworkFile ¶
func (filesystem *Filesystem) DownloadNetworkFile(networkFileUrl, filePath string) error
DownloadNetworkFile 下载网络文件到本地
func (*Filesystem) EditorUpload ¶
func (filesystem *Filesystem) EditorUpload(fileBytes []byte, allow config.FileAllow, field, filename, mime, ext string) (Info, error)
EditorUpload 编辑器文件上传
func (*Filesystem) FullPath ¶
func (filesystem *Filesystem) FullPath(filePath string) string
FullPath 完整路径
func (*Filesystem) HasDir ¶
func (filesystem *Filesystem) HasDir(file string) bool
func (*Filesystem) HasFile ¶
func (filesystem *Filesystem) HasFile(filePath string) bool
HasFile 判断文件是否存在
func (*Filesystem) NetworkFileSaveObject ¶
func (filesystem *Filesystem) NetworkFileSaveObject(networkFileUrl, filePath, mime string) (bool, error)
NetworkFileSaveObject 保存网络文件到存储器
func (*Filesystem) OriginalPath ¶
func (filesystem *Filesystem) OriginalPath(filePath string) string
OriginalPath 原始文件路径
func (*Filesystem) Storage ¶
func (filesystem *Filesystem) Storage() adapter.Adapter
func (*Filesystem) Upload ¶
func (filesystem *Filesystem) Upload(file *multipart.FileHeader, allow config.FileAllow, field string) (Info, error)
Upload 文件上传
type Info ¶
type Info struct {
Id uint64 `json:"id"`
Path string `json:"path"`
FileMd5 string `json:"file_md5"`
Sha1 string `json:"sha1"`
Filename string `json:"filename"`
Ext string `json:"ext"`
MimeType string `json:"mime_type"`
FileSize uint64 `json:"file_size"`
Width uint64 `json:"width"`
Height uint64 `json:"height"`
Attach string `json:"attach"`
Code int `json:"code"`
IsImage uint8 `json:"is_image"`
}
Info 文件信息
Click to show internal directories.
Click to hide internal directories.