Merge remote-tracking branch 'origin/tuoyun' into tuoyun

pull/232/head
wenxu12345 3 years ago
commit 74cea2b41c

@ -62,37 +62,18 @@ func UploadUpdateApp(c *gin.Context) {
c.JSON(http.StatusBadRequest, gin.H{"errCode": 400, "errMsg": "invalid file type" + err.Error()})
return
}
file, err := c.FormFile("file")
if err != nil {
log.NewError(req.OperationID, utils.GetSelfFuncName(), "missing file arg", err.Error())
c.JSON(http.StatusBadRequest, gin.H{"errCode": 400, "errMsg": "missing file arg: " + err.Error()})
return
}
fileObj, err := file.Open()
fileObj, err := req.File.Open()
yamlObj, err := req.Yaml.Open()
if err != nil {
log.NewError(req.OperationID, utils.GetSelfFuncName(), "Open file error", err.Error())
c.JSON(http.StatusBadRequest, gin.H{"errCode": 400, "errMsg": "Open file error:" + err.Error()})
return
}
yaml, err := c.FormFile("yaml")
if err != nil {
log.NewError(req.OperationID, utils.GetSelfFuncName(), "missing yaml arg", err.Error())
c.JSON(http.StatusBadRequest, gin.H{"errCode": 400, "errMsg": "missing yaml arg: " + err.Error()})
return
}
yamlObj, err := yaml.Open()
if err != nil {
log.NewError(req.OperationID, utils.GetSelfFuncName(), "open yaml failed", err.Error())
c.JSON(http.StatusBadRequest, gin.H{"errCode": 400, "errMsg": "Open file error:" + err.Error()})
c.JSON(http.StatusBadRequest, gin.H{"errCode": 400, "errMsg": "invalid file path" + err.Error()})
return
}
//fmt.Println(req.OperationID, utils.GetSelfFuncName(), "name: ", newFileName, newYamlName, fileObj, yamlObj, file.Size, yaml.Size)
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "name: ", newFileName, newYamlName, fileObj, yamlObj, req.File.Size, req.Yaml.Size)
// v2.0.9_app_linux v2.0.9_yaml_linux
_, 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, newYamlName, yamlObj, yaml.Size, minio.PutObjectOptions{})
_, newType := utils.GetNewFileNameAndContentType("", constant.OtherType)
_, err = apiThird.MinioClient.PutObject(context.Background(), config.Config.Credential.Minio.AppBucket, newFileName, fileObj, req.File.Size, minio.PutObjectOptions{ContentType: newType})
_, err = apiThird.MinioClient.PutObject(context.Background(), config.Config.Credential.Minio.AppBucket, newYamlName, yamlObj, req.Yaml.Size, minio.PutObjectOptions{ContentType: newType})
if err != nil {
log.NewError(req.OperationID, utils.GetSelfFuncName(), "open file error")
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": "invalid file path" + err.Error()})

@ -2,6 +2,7 @@ package cms_api_struct
import (
apiStruct "Open_IM/pkg/base_info"
"mime/multipart"
)
type AdminLoginRequest struct {
@ -17,8 +18,8 @@ type UploadUpdateAppReq struct {
OperationID string `form:"operationID" binding:"required"`
Type int `form:"type" binding:"required"`
Version string `form:"version" binding:"required"`
//File multipart.FileHeader `form:"file" binding:"required"`
//Yaml multipart.FileHeader `form:"yaml" binding:"required"`
File multipart.FileHeader `form:"file" binding:"required"`
Yaml multipart.FileHeader `form:"yaml" binding:"required"`
ForceUpdate bool `form:"forceUpdate" binding:"required"`
}

Loading…
Cancel
Save