mirror of
https://github.com/openimsdk/open-im-server.git
synced 2025-04-26 11:36:44 +08:00
update app
This commit is contained in:
parent
1efa654e7d
commit
e412abd017
@ -14,6 +14,7 @@ import (
|
|||||||
"fmt"
|
"fmt"
|
||||||
"github.com/minio/minio-go/v7"
|
"github.com/minio/minio-go/v7"
|
||||||
"net/http"
|
"net/http"
|
||||||
|
"path"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"Open_IM/internal/api/third"
|
"Open_IM/internal/api/third"
|
||||||
@ -64,22 +65,31 @@ func UploadUpdateApp(c *gin.Context) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
fileObj, err := req.File.Open()
|
fileObj, err := req.File.Open()
|
||||||
yamlObj, err := req.Yaml.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": "invalid file path" + 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
|
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
|
// v2.0.9_app_linux v2.0.9_yaml_linux
|
||||||
_, newType := utils.GetNewFileNameAndContentType("", constant.OtherType)
|
_, 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: newType})
|
|
||||||
_, err = apiThird.MinioClient.PutObject(context.Background(), config.Config.Credential.Minio.AppBucket, newYamlName, yamlObj, req.Yaml.Size, minio.PutObjectOptions{ContentType: newType})
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.NewError(req.OperationID, utils.GetSelfFuncName(), "open file error")
|
log.NewError(req.OperationID, utils.GetSelfFuncName(), "PutObject 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": "PutObject file error" + err.Error()})
|
||||||
|
return
|
||||||
|
}
|
||||||
|
_, err = apiThird.MinioClient.PutObject(context.Background(), config.Config.Credential.Minio.AppBucket, newYamlName, yamlObj, req.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()})
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
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 {
|
||||||
|
@ -15,12 +15,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