2018-01-10 18:20:32 +08:00
|
|
|
package main
|
|
|
|
|
|
|
|
|
|
import (
|
2019-04-03 00:03:46 +08:00
|
|
|
"fmt"
|
2020-06-03 00:09:51 +08:00
|
|
|
"github.com/gogf/gf/frame/g"
|
|
|
|
|
"path/filepath"
|
2019-07-29 21:01:19 +08:00
|
|
|
|
|
|
|
|
"github.com/gogf/gf/net/ghttp"
|
|
|
|
|
"github.com/gogf/gf/os/glog"
|
2018-01-10 18:20:32 +08:00
|
|
|
)
|
|
|
|
|
|
2020-06-03 00:09:51 +08:00
|
|
|
func SendXmlFile(gameId int, areaName string, filePath string) error {
|
|
|
|
|
path := filepath.FromSlash(filePath)
|
|
|
|
|
fmt.Println(path)
|
|
|
|
|
data := g.Map{
|
|
|
|
|
"gameName": gameId,
|
|
|
|
|
"area": areaName,
|
|
|
|
|
"file": "@file:" + path,
|
|
|
|
|
"contentType": "json",
|
|
|
|
|
}
|
|
|
|
|
if r, err := ghttp.Post("http://127.0.0.1:8199/upload", data); err != nil {
|
|
|
|
|
panic(err)
|
|
|
|
|
} else {
|
|
|
|
|
defer r.Close()
|
|
|
|
|
fmt.Println("ok")
|
|
|
|
|
}
|
|
|
|
|
return nil
|
|
|
|
|
}
|
|
|
|
|
|
2018-01-10 18:20:32 +08:00
|
|
|
func main() {
|
2020-06-03 00:09:51 +08:00
|
|
|
SendXmlFile(1, "xxx", "/Users/john/Workspace/Go/GOPATH/src/github.com/gogf/gf/.example/net/ghttp/server/session.go")
|
|
|
|
|
return
|
2019-04-03 00:03:46 +08:00
|
|
|
path := "/home/john/Workspace/Go/github.com/gogf/gf/version.go"
|
2019-11-06 10:39:59 +08:00
|
|
|
r, e := ghttp.Post("http://127.0.0.1:8199/upload", "upload-file=@file:"+path)
|
2019-04-03 00:03:46 +08:00
|
|
|
if e != nil {
|
|
|
|
|
glog.Error(e)
|
|
|
|
|
} else {
|
|
|
|
|
fmt.Println(string(r.ReadAll()))
|
|
|
|
|
r.Close()
|
|
|
|
|
}
|
|
|
|
|
}
|