mirror of
https://github.com/siyuan-note/siyuan.git
synced 2026-01-03 23:38:49 +01:00
🎨 改进 网络图片转换为本地图片 文件名后缀 Fix https://github.com/siyuan-note/siyuan/issues/5053
This commit is contained in:
parent
c57014c12e
commit
a43c5c5b40
8 changed files with 231 additions and 9 deletions
|
|
@ -34,6 +34,7 @@ import (
|
|||
"github.com/88250/gulu"
|
||||
"github.com/88250/lute/ast"
|
||||
"github.com/88250/lute/parse"
|
||||
"github.com/gabriel-vasile/mimetype"
|
||||
"github.com/siyuan-note/siyuan/kernel/filesys"
|
||||
"github.com/siyuan-note/siyuan/kernel/search"
|
||||
"github.com/siyuan-note/siyuan/kernel/sql"
|
||||
|
|
@ -116,6 +117,11 @@ func NetImg2LocalAssets(rootID string) (err error) {
|
|||
}
|
||||
name, _ = url.PathUnescape(name)
|
||||
ext := path.Ext(name)
|
||||
if "" == ext {
|
||||
if mtype := mimetype.Detect(data); nil != mtype {
|
||||
ext = mtype.Extension()
|
||||
}
|
||||
}
|
||||
if "" == ext {
|
||||
contentType := resp.Header.Get("Content-Type")
|
||||
exts, _ := mime.ExtensionsByType(contentType)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue