From 863d64b53ab589524b5817df3819497ab85e15cf Mon Sep 17 00:00:00 2001 From: jiangyong Date: Fri, 13 Mar 2026 12:02:01 +0800 Subject: [PATCH] storage --- storage/minio.go | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/storage/minio.go b/storage/minio.go index 3ce9d83..21adf50 100644 --- a/storage/minio.go +++ b/storage/minio.go @@ -169,10 +169,11 @@ func (s *Minio) Fetch(urlStr, objectName string) error { // 获取文件名和 Content-Type objectName = strings.TrimLeft(objectName, "/ ") - contentType := resp.Header.Get("Content-Type") + // 优先根据文件扩展名推断 Content-Type,确保图片能正确预览 + ext := strings.TrimLeft(path.Ext(objectName), ".") + contentType := ext2ContentType(ext) if contentType == "" { - ext := strings.TrimLeft(path.Ext(objectName), ".") - contentType = ext2ContentType(ext) + contentType = resp.Header.Get("Content-Type") } // 上传到 MinIO