添加文件内容创建接口,获取待转换文件列表的文件类型过滤
This commit is contained in:
parent
3071926f11
commit
fcd37a598d
|
|
@ -338,9 +338,33 @@ func GetFileWillConvertContentFileList(userID int) ([]dao.File, error) {
|
|||
if user.Role != "admin" {
|
||||
return nil, errors.New("no permission")
|
||||
}
|
||||
return dao.GetFileWillConvertContentFileList()
|
||||
files, err2 := dao.GetFileWillConvertContentFileList()
|
||||
if err2 != nil {
|
||||
return nil, err2
|
||||
}
|
||||
var res []dao.File
|
||||
for _, file := range files {
|
||||
fileType := strings.Split(file.FileStoreName, ".")[1]
|
||||
//如果文件类型是图片则不需要返回
|
||||
if fileType == "jpg" || fileType == "png" || fileType == "jpeg" || fileType == "gif" {
|
||||
continue
|
||||
}
|
||||
//如果文件类型是视频则不需要返回
|
||||
if fileType == "mp4" || fileType == "avi" || fileType == "rmvb" || fileType == "mkv" {
|
||||
continue
|
||||
}
|
||||
//如果文件类型是音频则不需要返回
|
||||
if fileType == "mp3" || fileType == "wav" || fileType == "wma" {
|
||||
continue
|
||||
}
|
||||
//如果文件类型是压缩包则不需要返回
|
||||
if fileType == "zip" || fileType == "rar" || fileType == "7z" {
|
||||
continue
|
||||
}
|
||||
res = append(res, file)
|
||||
}
|
||||
return res, nil
|
||||
}
|
||||
|
||||
func readFileContent(filePath string) (string, error) {
|
||||
file, err := os.Open(filePath)
|
||||
if err != nil {
|
||||
|
|
|
|||
Loading…
Reference in New Issue