fix(storage): auto-detect content-type to resolve image rendering issues

Fixes #995. Added mime type detection in SaveBytes for MinIO, OSS, S3, and TOS to prevent images from being incorrectly saved as text/csv.
This commit is contained in:
jw_mac
2026-04-20 19:14:55 +08:00
committed by lyingbug
parent ede7dd08a2
commit 09e1642335
5 changed files with 64 additions and 59 deletions
+1 -1
View File
@@ -177,7 +177,7 @@ func (s *minioFileService) SaveBytes(ctx context.Context, data []byte, tenantID
// Upload bytes to MinIO
reader := bytes.NewReader(data)
_, err = s.client.PutObject(ctx, s.bucketName, objectName, reader, int64(len(data)), minio.PutObjectOptions{
ContentType: "text/csv; charset=utf-8",
ContentType: utils.GetContentTypeByExt(ext),
})
if err != nil {
return "", fmt.Errorf("failed to upload bytes to MinIO: %w", err)