mirror of
https://github.com/openimsdk/open-im-server.git
synced 2025-05-29 09:19:18 +08:00
update app
This commit is contained in:
parent
e412abd017
commit
f85645a78a
@ -53,7 +53,7 @@ func UploadUpdateApp(c *gin.Context) {
|
|||||||
resp apiStruct.UploadUpdateAppResp
|
resp apiStruct.UploadUpdateAppResp
|
||||||
)
|
)
|
||||||
if err := c.Bind(&req); err != nil {
|
if err := c.Bind(&req); err != nil {
|
||||||
log.NewError("0", utils.GetSelfFuncName(), "BindJSON failed ", err.Error())
|
log.NewError(req.OperationID, utils.GetSelfFuncName(), "BindJSON failed ", err.Error())
|
||||||
c.JSON(http.StatusBadRequest, gin.H{"errCode": 400, "errMsg": err.Error()})
|
c.JSON(http.StatusBadRequest, gin.H{"errCode": 400, "errMsg": err.Error()})
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@ -64,22 +64,49 @@ 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()
|
//fileObj, err := req.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
|
||||||
|
//}
|
||||||
|
//yamlObj, err := req.Yaml.Open()
|
||||||
|
//if err != nil {
|
||||||
|
// log.NewError(req.OperationID, utils.GetSelfFuncName(), "Open Yaml error", err.Error())
|
||||||
|
// c.JSON(http.StatusBadRequest, gin.H{"errCode": 400, "errMsg": "Open Yaml error" + err.Error()})
|
||||||
|
// return
|
||||||
|
//}
|
||||||
|
|
||||||
|
// v2.0.9_app_linux v2.0.9_yaml_linux
|
||||||
|
file, err := c.FormFile("file")
|
||||||
|
if err != nil {
|
||||||
|
log.NewError(req.OperationID, utils.GetSelfFuncName(), "FormFile failed", err.Error())
|
||||||
|
c.JSON(http.StatusBadRequest, gin.H{"errCode": 400, "errMsg": "missing file arg: " + err.Error()})
|
||||||
|
return
|
||||||
|
}
|
||||||
|
fileObj, err := file.Open()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.NewError(req.OperationID, utils.GetSelfFuncName(), "Open file error", err.Error())
|
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()})
|
c.JSON(http.StatusBadRequest, gin.H{"errCode": 400, "errMsg": "invalid file path" + err.Error()})
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
yamlObj, err := req.Yaml.Open()
|
|
||||||
|
yaml, err := c.FormFile("yaml")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.NewError(req.OperationID, utils.GetSelfFuncName(), "Open Yaml error", err.Error())
|
log.NewError(req.OperationID, utils.GetSelfFuncName(), "FormFile failed", err.Error())
|
||||||
c.JSON(http.StatusBadRequest, gin.H{"errCode": 400, "errMsg": "Open Yaml error" + err.Error()})
|
c.JSON(http.StatusBadRequest, gin.H{"errCode": 400, "errMsg": "missing file arg: " + err.Error()})
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
yamlObj, err := 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": "invalid file path" + err.Error()})
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
fmt.Println(req.OperationID, utils.GetSelfFuncName(), "name: ", config.Config.Credential.Minio.AppBucket, newFileName, fileObj, req.File.Size)
|
fmt.Println(req.OperationID, utils.GetSelfFuncName(), "name: ", config.Config.Credential.Minio.AppBucket, newFileName, fileObj, req.File.Size)
|
||||||
fmt.Println(req.OperationID, utils.GetSelfFuncName(), "name: ", config.Config.Credential.Minio.AppBucket, newYamlName, yamlObj, req.Yaml.Size)
|
fmt.Println(req.OperationID, utils.GetSelfFuncName(), "name: ", config.Config.Credential.Minio.AppBucket, newYamlName, yamlObj, 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, req.File.Size, minio.PutObjectOptions{ContentType: path.Ext(newFileName)})
|
_, err = apiThird.MinioClient.PutObject(context.Background(), config.Config.Credential.Minio.AppBucket, newFileName, fileObj, req.File.Size, minio.PutObjectOptions{ContentType: path.Ext(newFileName)})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.NewError(req.OperationID, utils.GetSelfFuncName(), "PutObject file error")
|
log.NewError(req.OperationID, utils.GetSelfFuncName(), "PutObject file error")
|
||||||
|
@ -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 {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user