🎨 改进 网络图片转换为本地图片
文件名后缀 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
|
@ -261,6 +261,7 @@ SiYuan is made possible by the following open source projects.
|
|||
* [https://github.com/facette/natsort](https://github.com/facette/natsort) `BSD-3-Clause License`
|
||||
* [https://github.com/flopp/go-findfont](https://github.com/flopp/go-findfont) `MIT License`
|
||||
* [https://github.com/fsnotify/fsnotify](https://github.com/fsnotify/fsnotify) `BSD-3-Clause License`
|
||||
* [https://github.com/gabriel-vasile/mimetype](https://github.com/gabriel-vasile/mimetype) `MIT License`
|
||||
* [https://github.com/gin-contrib/cors](https://github.com/gin-contrib/cors) `MIT License`
|
||||
* [https://github.com/gin-contrib/gzip](https://github.com/gin-contrib/gzip) `MIT License`
|
||||
* [https://github.com/gin-contrib/sessions](https://github.com/gin-contrib/sessions) `MIT License`
|
||||
|
|
|
@ -269,6 +269,7 @@
|
|||
* [https://github.com/facette/natsort](https://github.com/facette/natsort) `BSD-3-Clause License`
|
||||
* [https://github.com/flopp/go-findfont](https://github.com/flopp/go-findfont) `MIT License`
|
||||
* [https://github.com/fsnotify/fsnotify](https://github.com/fsnotify/fsnotify) `BSD-3-Clause License`
|
||||
* [https://github.com/gabriel-vasile/mimetype](https://github.com/gabriel-vasile/mimetype) `MIT License`
|
||||
* [https://github.com/gin-contrib/cors](https://github.com/gin-contrib/cors) `MIT License`
|
||||
* [https://github.com/gin-contrib/gzip](https://github.com/gin-contrib/gzip) `MIT License`
|
||||
* [https://github.com/gin-contrib/sessions](https://github.com/gin-contrib/sessions) `MIT License`
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
"id": "20201121224345-rc27qvo",
|
||||
"title": "Acknowledgements",
|
||||
"type": "doc",
|
||||
"updated": "20220522101213"
|
||||
"updated": "20220530180108"
|
||||
},
|
||||
"Children": [
|
||||
{
|
||||
|
@ -29,7 +29,7 @@
|
|||
"ListData": {},
|
||||
"Properties": {
|
||||
"id": "20220522101213-z3hokh2",
|
||||
"updated": "20220522101213"
|
||||
"updated": "20220530180108"
|
||||
},
|
||||
"Children": [
|
||||
{
|
||||
|
@ -1572,6 +1572,76 @@
|
|||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"ID": "20220530180107-u2pjucg",
|
||||
"Type": "NodeListItem",
|
||||
"ListData": {
|
||||
"BulletChar": 42,
|
||||
"Marker": "Kg=="
|
||||
},
|
||||
"Properties": {
|
||||
"id": "20220530180107-u2pjucg",
|
||||
"updated": "20220530180108"
|
||||
},
|
||||
"Children": [
|
||||
{
|
||||
"ID": "20220530180107-zbx81j2",
|
||||
"Type": "NodeParagraph",
|
||||
"Properties": {
|
||||
"id": "20220530180107-zbx81j2",
|
||||
"updated": "20220530180108"
|
||||
},
|
||||
"Children": [
|
||||
{
|
||||
"Type": "NodeLink",
|
||||
"Data": "span",
|
||||
"Children": [
|
||||
{
|
||||
"Type": "NodeOpenBracket"
|
||||
},
|
||||
{
|
||||
"Type": "NodeLinkText",
|
||||
"Data": "https://github.com/gabriel-vasile/mimetype"
|
||||
},
|
||||
{
|
||||
"Type": "NodeCloseBracket"
|
||||
},
|
||||
{
|
||||
"Type": "NodeOpenParen"
|
||||
},
|
||||
{
|
||||
"Type": "NodeLinkDest",
|
||||
"Data": "https://github.com/gabriel-vasile/mimetype"
|
||||
},
|
||||
{
|
||||
"Type": "NodeCloseParen"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"Type": "NodeText",
|
||||
"Data": " "
|
||||
},
|
||||
{
|
||||
"Type": "NodeCodeSpan",
|
||||
"Data": "code",
|
||||
"Children": [
|
||||
{
|
||||
"Type": "NodeCodeSpanOpenMarker"
|
||||
},
|
||||
{
|
||||
"Type": "NodeCodeSpanContent",
|
||||
"Data": "MIT License"
|
||||
},
|
||||
{
|
||||
"Type": "NodeCodeSpanCloseMarker"
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"ID": "20220522101213-xvc77du",
|
||||
"Type": "NodeListItem",
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
"id": "20201121212605-9td1a62",
|
||||
"title": "致谢",
|
||||
"type": "doc",
|
||||
"updated": "20220522101224"
|
||||
"updated": "20220530180055"
|
||||
},
|
||||
"Children": [
|
||||
{
|
||||
|
@ -29,7 +29,7 @@
|
|||
"ListData": {},
|
||||
"Properties": {
|
||||
"id": "20220522101224-ctmcj3d",
|
||||
"updated": "20220522101224"
|
||||
"updated": "20220530180055"
|
||||
},
|
||||
"Children": [
|
||||
{
|
||||
|
@ -1511,7 +1511,7 @@
|
|||
},
|
||||
"Properties": {
|
||||
"id": "20220522101224-gbd2na7",
|
||||
"updated": "20220522101224"
|
||||
"updated": "20220530180049"
|
||||
},
|
||||
"Children": [
|
||||
{
|
||||
|
@ -1519,7 +1519,7 @@
|
|||
"Type": "NodeParagraph",
|
||||
"Properties": {
|
||||
"id": "20220522101224-mwz2rxp",
|
||||
"updated": "20220522101224"
|
||||
"updated": "20220530180049"
|
||||
},
|
||||
"Children": [
|
||||
{
|
||||
|
@ -1572,6 +1572,76 @@
|
|||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"ID": "20220530180049-796wwcg",
|
||||
"Type": "NodeListItem",
|
||||
"ListData": {
|
||||
"BulletChar": 42,
|
||||
"Marker": "Kg=="
|
||||
},
|
||||
"Properties": {
|
||||
"id": "20220530180049-796wwcg",
|
||||
"updated": "20220530180055"
|
||||
},
|
||||
"Children": [
|
||||
{
|
||||
"ID": "20220530180049-qvs3gi0",
|
||||
"Type": "NodeParagraph",
|
||||
"Properties": {
|
||||
"id": "20220530180049-qvs3gi0",
|
||||
"updated": "20220530180055"
|
||||
},
|
||||
"Children": [
|
||||
{
|
||||
"Type": "NodeLink",
|
||||
"Data": "span",
|
||||
"Children": [
|
||||
{
|
||||
"Type": "NodeOpenBracket"
|
||||
},
|
||||
{
|
||||
"Type": "NodeLinkText",
|
||||
"Data": "https://github.com/gabriel-vasile/mimetype"
|
||||
},
|
||||
{
|
||||
"Type": "NodeCloseBracket"
|
||||
},
|
||||
{
|
||||
"Type": "NodeOpenParen"
|
||||
},
|
||||
{
|
||||
"Type": "NodeLinkDest",
|
||||
"Data": "https://github.com/gabriel-vasile/mimetype"
|
||||
},
|
||||
{
|
||||
"Type": "NodeCloseParen"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"Type": "NodeText",
|
||||
"Data": " "
|
||||
},
|
||||
{
|
||||
"Type": "NodeCodeSpan",
|
||||
"Data": "code",
|
||||
"Children": [
|
||||
{
|
||||
"Type": "NodeCodeSpanOpenMarker"
|
||||
},
|
||||
{
|
||||
"Type": "NodeCodeSpanContent",
|
||||
"Data": "MIT License"
|
||||
},
|
||||
{
|
||||
"Type": "NodeCodeSpanCloseMarker"
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"ID": "20220522101224-rb7cnss",
|
||||
"Type": "NodeListItem",
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
"icon": "1f64f",
|
||||
"id": "20211226114929-08ap1r0",
|
||||
"title": "致謝",
|
||||
"updated": "20220522101124"
|
||||
"updated": "20220530180118"
|
||||
},
|
||||
"Children": [
|
||||
{
|
||||
|
@ -28,7 +28,7 @@
|
|||
"ListData": {},
|
||||
"Properties": {
|
||||
"id": "20220326092650-r61gazd",
|
||||
"updated": "20220522101124"
|
||||
"updated": "20220530180118"
|
||||
},
|
||||
"Children": [
|
||||
{
|
||||
|
@ -1571,6 +1571,76 @@
|
|||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"ID": "20220530180117-4u0c53m",
|
||||
"Type": "NodeListItem",
|
||||
"ListData": {
|
||||
"BulletChar": 42,
|
||||
"Marker": "Kg=="
|
||||
},
|
||||
"Properties": {
|
||||
"id": "20220530180117-4u0c53m",
|
||||
"updated": "20220530180118"
|
||||
},
|
||||
"Children": [
|
||||
{
|
||||
"ID": "20220530180117-wnowy4x",
|
||||
"Type": "NodeParagraph",
|
||||
"Properties": {
|
||||
"id": "20220530180117-wnowy4x",
|
||||
"updated": "20220530180118"
|
||||
},
|
||||
"Children": [
|
||||
{
|
||||
"Type": "NodeLink",
|
||||
"Data": "span",
|
||||
"Children": [
|
||||
{
|
||||
"Type": "NodeOpenBracket"
|
||||
},
|
||||
{
|
||||
"Type": "NodeLinkText",
|
||||
"Data": "https://github.com/gabriel-vasile/mimetype"
|
||||
},
|
||||
{
|
||||
"Type": "NodeCloseBracket"
|
||||
},
|
||||
{
|
||||
"Type": "NodeOpenParen"
|
||||
},
|
||||
{
|
||||
"Type": "NodeLinkDest",
|
||||
"Data": "https://github.com/gabriel-vasile/mimetype"
|
||||
},
|
||||
{
|
||||
"Type": "NodeCloseParen"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"Type": "NodeText",
|
||||
"Data": " "
|
||||
},
|
||||
{
|
||||
"Type": "NodeCodeSpan",
|
||||
"Data": "code",
|
||||
"Children": [
|
||||
{
|
||||
"Type": "NodeCodeSpanOpenMarker"
|
||||
},
|
||||
{
|
||||
"Type": "NodeCodeSpanContent",
|
||||
"Data": "MIT License"
|
||||
},
|
||||
{
|
||||
"Type": "NodeCodeSpanCloseMarker"
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"ID": "20220326092650-zmj3bdd",
|
||||
"Type": "NodeListItem",
|
||||
|
|
|
@ -24,6 +24,7 @@ require (
|
|||
github.com/facette/natsort v0.0.0-20181210072756-2cd4dd1e2dcb
|
||||
github.com/flopp/go-findfont v0.1.0
|
||||
github.com/fsnotify/fsnotify v1.5.4
|
||||
github.com/gabriel-vasile/mimetype v1.4.0
|
||||
github.com/getsentry/sentry-go v0.13.0
|
||||
github.com/gin-contrib/cors v1.3.1
|
||||
github.com/gin-contrib/gzip v0.0.5
|
||||
|
@ -32,6 +33,7 @@ require (
|
|||
github.com/imroc/req/v3 v3.11.3
|
||||
github.com/jinzhu/copier v0.3.5
|
||||
github.com/mattn/go-sqlite3 v2.0.3+incompatible
|
||||
github.com/mattn/go-zglob v0.0.3
|
||||
github.com/mitchellh/go-ps v1.0.0
|
||||
github.com/mssola/user_agent v0.5.3
|
||||
github.com/panjf2000/ants/v2 v2.5.0
|
||||
|
@ -78,7 +80,6 @@ require (
|
|||
github.com/juju/errors v0.0.0-20220331221717-b38fca44723b // indirect
|
||||
github.com/leodido/go-urn v1.2.1 // indirect
|
||||
github.com/mattn/go-isatty v0.0.14 // indirect
|
||||
github.com/mattn/go-zglob v0.0.3 // indirect
|
||||
github.com/mitchellh/copystructure v1.2.0 // indirect
|
||||
github.com/mitchellh/reflectwalk v1.0.2 // indirect
|
||||
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
|
||||
|
|
|
@ -136,6 +136,8 @@ github.com/frankban/quicktest v1.14.3 h1:FJKSZTDHjyhriyC81FLQ0LY93eSai0ZyR/ZIkd3
|
|||
github.com/fsnotify/fsnotify v1.4.9/go.mod h1:znqG4EE+3YCdAaPaxE2ZRY/06pZUdp0tY4IgpuI1SZQ=
|
||||
github.com/fsnotify/fsnotify v1.5.4 h1:jRbGcIw6P2Meqdwuo0H1p6JVLbL5DHKAKlYndzMwVZI=
|
||||
github.com/fsnotify/fsnotify v1.5.4/go.mod h1:OVB6XrOHzAwXMpEM7uPOzcehqUV2UqJxmVXmkdnm1bU=
|
||||
github.com/gabriel-vasile/mimetype v1.4.0 h1:Cn9dkdYsMIu56tGho+fqzh7XmvY2YyGU0FnbhiOsEro=
|
||||
github.com/gabriel-vasile/mimetype v1.4.0/go.mod h1:fA8fi6KUiG7MgQQ+mEWotXoEOvmxRtOJlERCzSmRvr8=
|
||||
github.com/getsentry/sentry-go v0.13.0 h1:20dgTiUSfxRB/EhMPtxcL9ZEbM1ZdR+W/7f7NWD+xWo=
|
||||
github.com/getsentry/sentry-go v0.13.0/go.mod h1:EOsfu5ZdvKPfeHYV6pTVQnsjfp30+XA7//UooKNumH0=
|
||||
github.com/ghodss/yaml v1.0.0/go.mod h1:4dBDuWmgqj2HViK6kFavaiC9ZROes6MMH2rRYeMEF04=
|
||||
|
@ -554,6 +556,7 @@ golang.org/x/net v0.0.0-20210119194325-5f4716e94777/go.mod h1:m0MpNAwzfU5UDzcl9v
|
|||
golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg=
|
||||
golang.org/x/net v0.0.0-20210316092652-d523dce5a7f4/go.mod h1:RBQZq4jEuRlivfhVLdyRGr576XBO4/greRjx4P4O3yc=
|
||||
golang.org/x/net v0.0.0-20210405180319-a5a99cb37ef4/go.mod h1:p54w0d4576C0XHj96bSt6lcn1PtDYWL6XObtHCRCNQM=
|
||||
golang.org/x/net v0.0.0-20210505024714-0287a6fb4125/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y=
|
||||
golang.org/x/net v0.0.0-20210805182204-aaa1db679c0d/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y=
|
||||
golang.org/x/net v0.0.0-20210916014120-12bc252f5db8/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y=
|
||||
golang.org/x/net v0.0.0-20211112202133-69e39bad7dc2/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y=
|
||||
|
|
|
@ -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
Reference in a new issue