update app

This commit is contained in:
wangchuxiao 2022-05-10 11:40:40 +08:00
parent 8af500462f
commit e27b98cdc1
2 changed files with 33 additions and 14 deletions

View File

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

View File

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