mirror of
https://github.com/openimsdk/open-im-server.git
synced 2025-05-24 13:59:17 +08:00
update app
This commit is contained in:
parent
e314fd4a0a
commit
2c89d80a27
@ -161,7 +161,13 @@ func UploadUpdateApp(c *gin.Context) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "req: ", req)
|
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "req: ", req)
|
||||||
newFileName, newYamlName, err := utils.GetUploadAppNewName(req.Type, req.Version, req.File.Filename, req.Yaml.Filename)
|
var yamlName string
|
||||||
|
if req.Yaml == nil {
|
||||||
|
yamlName = ""
|
||||||
|
} else {
|
||||||
|
yamlName = req.Yaml.Filename
|
||||||
|
}
|
||||||
|
newFileName, newYamlName, err := utils.GetUploadAppNewName(req.Type, req.Version, req.File.Filename, yamlName)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.NewError(req.OperationID, utils.GetSelfFuncName(), "GetUploadAppNewName failed", err.Error())
|
log.NewError(req.OperationID, utils.GetSelfFuncName(), "GetUploadAppNewName failed", err.Error())
|
||||||
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()})
|
||||||
@ -179,18 +185,19 @@ func UploadUpdateApp(c *gin.Context) {
|
|||||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": "PutObject file error" + err.Error()})
|
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": "PutObject file error" + err.Error()})
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
if newYamlName != "" {
|
||||||
yamlObj, err := req.Yaml.Open()
|
yamlObj, err := req.Yaml.Open()
|
||||||
if err == nil {
|
if err == nil {
|
||||||
_, err = MinioClient.PutObject(context.Background(), config.Config.Credential.Minio.AppBucket, newYamlName, yamlObj, req.Yaml.Size, minio.PutObjectOptions{ContentType: path.Ext(newYamlName)})
|
_, err = MinioClient.PutObject(context.Background(), config.Config.Credential.Minio.AppBucket, newYamlName, yamlObj, req.Yaml.Size, minio.PutObjectOptions{ContentType: path.Ext(newYamlName)})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.NewError(req.OperationID, utils.GetSelfFuncName(), "PutObject yaml error")
|
log.NewError(req.OperationID, utils.GetSelfFuncName(), "PutObject yaml error")
|
||||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": "PutObject yaml error" + err.Error()})
|
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": "PutObject yaml error" + err.Error()})
|
||||||
return
|
return
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
log.NewError(req.OperationID, utils.GetSelfFuncName(), err.Error())
|
||||||
|
newYamlName = ""
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
log.NewError(req.OperationID, utils.GetSelfFuncName(), err.Error())
|
|
||||||
newYamlName = ""
|
|
||||||
}
|
}
|
||||||
if err := imdb.UpdateAppVersion(req.Type, req.Version, req.ForceUpdate, newFileName, newYamlName); err != nil {
|
if err := imdb.UpdateAppVersion(req.Type, req.Version, req.ForceUpdate, newFileName, newYamlName); err != nil {
|
||||||
log.NewError(req.OperationID, utils.GetSelfFuncName(), "UpdateAppVersion error", err.Error())
|
log.NewError(req.OperationID, utils.GetSelfFuncName(), "UpdateAppVersion error", err.Error())
|
||||||
|
@ -70,5 +70,8 @@ func GetUploadAppNewName(appType int, version, fileName, yamlName string) (strin
|
|||||||
suffixYaml := path.Ext(yamlName)
|
suffixYaml := path.Ext(yamlName)
|
||||||
newFileName = fmt.Sprintf("%s%s", newFileName, suffixFile)
|
newFileName = fmt.Sprintf("%s%s", newFileName, suffixFile)
|
||||||
newYamlName = fmt.Sprintf("%s%s", newYamlName, suffixYaml)
|
newYamlName = fmt.Sprintf("%s%s", newYamlName, suffixYaml)
|
||||||
|
if yamlName == "" {
|
||||||
|
newYamlName = ""
|
||||||
|
}
|
||||||
return newFileName, newYamlName, nil
|
return newFileName, newYamlName, nil
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user