fix: ext issues

This commit is contained in:
Rogee
2024-09-06 18:10:06 +08:00
parent 65dc698f5b
commit f8df3a59f0
4 changed files with 97 additions and 31 deletions

View File

@@ -4,6 +4,7 @@ import (
"context"
"mime"
"os"
"path/filepath"
"strings"
"exporter/pkg/errorx"
@@ -197,9 +198,11 @@ func (t *TClient) savePhoto(ctx context.Context, cfg *DBChannel, photo *tg.Photo
func (t *TClient) getExtByFilenameAndMimeType(filename, mimeType string) string {
ext := ""
if filename != "" {
ext = filename[strings.LastIndex(filename, "."):]
return ext
if filename != "" && strings.Contains(filename, ".") {
ext = filepath.Ext(filename)
if ext != "" {
return ext
}
}
exts, err := mime.ExtensionsByType(mimeType)