This commit is contained in:
jiangyong 2026-03-13 12:02:01 +08:00
parent 006c8de201
commit 863d64b53a
1 changed files with 4 additions and 3 deletions

View File

@ -169,10 +169,11 @@ func (s *Minio) Fetch(urlStr, objectName string) error {
// 获取文件名和 Content-Type
objectName = strings.TrimLeft(objectName, "/ ")
contentType := resp.Header.Get("Content-Type")
if contentType == "" {
// 优先根据文件扩展名推断 Content-Type确保图片能正确预览
ext := strings.TrimLeft(path.Ext(objectName), ".")
contentType = ext2ContentType(ext)
contentType := ext2ContentType(ext)
if contentType == "" {
contentType = resp.Header.Get("Content-Type")
}
// 上传到 MinIO