file type detection
This commit is contained in:
parent
a36b4e0631
commit
45428a5e79
@ -175,7 +175,7 @@ func (i *FileInfo) detectType(modify, saveContent bool) error {
|
|||||||
case strings.HasPrefix(mimetype, "image"):
|
case strings.HasPrefix(mimetype, "image"):
|
||||||
i.Type = "image"
|
i.Type = "image"
|
||||||
return nil
|
return nil
|
||||||
case strings.HasPrefix(mimetype, "application/object"):
|
case mimetype == "application/octet-stream" && is3DModelFile(i.Extension):
|
||||||
i.Type = "3dobject"
|
i.Type = "3dobject"
|
||||||
return nil
|
return nil
|
||||||
case isBinary(buffer[:n], n) || i.Size > 10*1024*1024: // 10 MB
|
case isBinary(buffer[:n], n) || i.Size > 10*1024*1024: // 10 MB
|
||||||
@ -202,6 +202,21 @@ func (i *FileInfo) detectType(modify, saveContent bool) error {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func is3DModelFile(ext string) bool {
|
||||||
|
switch strings.ToLower(ext) {
|
||||||
|
case
|
||||||
|
".obj",
|
||||||
|
".json",
|
||||||
|
".stl",
|
||||||
|
".dae",
|
||||||
|
".ply",
|
||||||
|
".fbx",
|
||||||
|
".gltf":
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
func (i *FileInfo) detectSubtitles() {
|
func (i *FileInfo) detectSubtitles() {
|
||||||
if i.Type != "video" {
|
if i.Type != "video" {
|
||||||
return
|
return
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user