diff --git a/internal/api/third/minio_storage_credential.go b/internal/api/third/minio_storage_credential.go index d6552518a..40ae13c4a 100644 --- a/internal/api/third/minio_storage_credential.go +++ b/internal/api/third/minio_storage_credential.go @@ -83,7 +83,7 @@ func MinioUploadFile(c *gin.Context) { return } newName, newType := utils.GetNewFileNameAndContentType(file.Filename, req.FileType) - log.Debug(req.OperationID, utils.GetSelfFuncName(), newName, newType) + log.Debug(req.OperationID, utils.GetSelfFuncName(), config.Config.Credential.Minio.Bucket, newName, fileObj, file.Size, newType) _, err = MinioClient.PutObject(context.Background(), config.Config.Credential.Minio.Bucket, newName, fileObj, file.Size, minio.PutObjectOptions{ContentType: newType}) if err != nil { log.NewError(req.OperationID, utils.GetSelfFuncName(), "upload file error") diff --git a/internal/cms_api/admin/admin.go b/internal/cms_api/admin/admin.go index 1c5754008..2f9d9e35c 100644 --- a/internal/cms_api/admin/admin.go +++ b/internal/cms_api/admin/admin.go @@ -14,6 +14,7 @@ import ( "fmt" "github.com/minio/minio-go/v7" "net/http" + "path" "strings" "Open_IM/internal/api/third" @@ -107,13 +108,13 @@ func UploadUpdateApp(c *gin.Context) { fmt.Println(req.OperationID, utils.GetSelfFuncName(), "name: ", config.Config.Credential.Minio.AppBucket, newFileName, fileObj, file.Size) fmt.Println(req.OperationID, utils.GetSelfFuncName(), "name: ", config.Config.Credential.Minio.AppBucket, newYamlName, yamlObj, yaml.Size) - _, err = apiThird.MinioClient.PutObject(context.Background(), config.Config.Credential.Minio.AppBucket, newFileName, fileObj, file.Size, minio.PutObjectOptions{}) + _, err = apiThird.MinioClient.PutObject(context.Background(), config.Config.Credential.Minio.AppBucket, newFileName, fileObj, file.Size, minio.PutObjectOptions{ContentType: path.Ext(newFileName)}) if err != nil { log.NewError(req.OperationID, utils.GetSelfFuncName(), "PutObject file error") c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": "PutObject file error" + err.Error()}) return } - _, err = apiThird.MinioClient.PutObject(context.Background(), config.Config.Credential.Minio.AppBucket, newYamlName, yamlObj, yaml.Size, minio.PutObjectOptions{}) + _, err = apiThird.MinioClient.PutObject(context.Background(), config.Config.Credential.Minio.AppBucket, newYamlName, yamlObj, yaml.Size, minio.PutObjectOptions{ContentType: path.Ext(newYamlName)}) if err != nil { log.NewError(req.OperationID, utils.GetSelfFuncName(), "PutObject yaml error") c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": "PutObject yaml error" + err.Error()})