mirror of
https://github.com/siyuan-note/siyuan.git
synced 2025-12-17 07:00:12 +01:00
🎨 Support opening assets through other apps on the Android https://github.com/siyuan-note/siyuan/issues/10657
This commit is contained in:
parent
1c9594be8e
commit
c5cc3ff779
2 changed files with 21 additions and 0 deletions
|
|
@ -99,6 +99,10 @@ func GetAssetAbsPath(asset string) (ret string) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func GetMimeTypeByExt(ext string) string {
|
||||||
|
return util.GetMimeTypeByExt(ext)
|
||||||
|
}
|
||||||
|
|
||||||
func SetTimezone(container, appDir, timezoneID string) {
|
func SetTimezone(container, appDir, timezoneID string) {
|
||||||
if "ios" == container {
|
if "ios" == container {
|
||||||
os.Setenv("ZONEINFO", filepath.Join(appDir, "app", "zoneinfo.zip"))
|
os.Setenv("ZONEINFO", filepath.Join(appDir, "app", "zoneinfo.zip"))
|
||||||
|
|
|
||||||
|
|
@ -20,6 +20,7 @@ import (
|
||||||
"bytes"
|
"bytes"
|
||||||
"io"
|
"io"
|
||||||
"io/fs"
|
"io/fs"
|
||||||
|
"mime"
|
||||||
"os"
|
"os"
|
||||||
"path"
|
"path"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
|
|
@ -28,10 +29,26 @@ import (
|
||||||
|
|
||||||
"github.com/88250/gulu"
|
"github.com/88250/gulu"
|
||||||
"github.com/88250/lute/ast"
|
"github.com/88250/lute/ast"
|
||||||
|
"github.com/gabriel-vasile/mimetype"
|
||||||
"github.com/siyuan-note/filelock"
|
"github.com/siyuan-note/filelock"
|
||||||
"github.com/siyuan-note/logging"
|
"github.com/siyuan-note/logging"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
func GetMimeTypeByExt(filePath string) (ret string) {
|
||||||
|
ret = mime.TypeByExtension(filepath.Ext(filePath))
|
||||||
|
if "" == ret {
|
||||||
|
m, err := mimetype.DetectFile(filePath)
|
||||||
|
if nil != err {
|
||||||
|
logging.LogErrorf("detect mime type of [%s] failed: %s", filePath, err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
if nil != m {
|
||||||
|
ret = m.String()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
func IsSymlinkPath(absPath string) bool {
|
func IsSymlinkPath(absPath string) bool {
|
||||||
fi, err := os.Lstat(absPath)
|
fi, err := os.Lstat(absPath)
|
||||||
if nil != err {
|
if nil != err {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue