43 lines
951 B
Go
43 lines
951 B
Go
package web
|
|
|
|
import (
|
|
"context"
|
|
"fmt"
|
|
"go_dreamfactory/comm"
|
|
"go_dreamfactory/lego/sys/gin/engine"
|
|
"go_dreamfactory/pb"
|
|
"go_dreamfactory/sys/configure"
|
|
"strconv"
|
|
)
|
|
|
|
//上传配置文件
|
|
func (this *Api_Comp) Upload(c *engine.Context) {
|
|
filenum := c.PostForm("filenum")
|
|
if filenum != "" {
|
|
if n, err := strconv.Atoi(filenum); err != nil {
|
|
this.module.Errorln(err)
|
|
return
|
|
} else {
|
|
for i := 0; i < n; i++ {
|
|
if fn, err := c.FormFile(fmt.Sprintf("file_%d", i)); err != nil {
|
|
this.module.Errorln(err)
|
|
return
|
|
} else {
|
|
if err = c.SaveUploadedFile(fn, fmt.Sprintf("%s/%s", configure.ConfigurePath(), fn.Filename)); err != nil {
|
|
this.module.Errorln(err)
|
|
return
|
|
}
|
|
}
|
|
}
|
|
}
|
|
if err := this.module.service.RpcBroadcast(
|
|
context.Background(),
|
|
comm.Service_Worker,
|
|
string(comm.Rpc_ConfigureUpDate),
|
|
&pb.EmptyReq{},
|
|
&pb.EmptyResp{}); err != nil {
|
|
this.module.Errorln(err)
|
|
}
|
|
}
|
|
}
|