feat: 添加文件上传工具及CI/CD配置
Some checks failed
构建上传工具 / build-tool (push) Failing after 22s

This commit is contained in:
2025-10-11 12:34:06 +08:00
parent cd068268b0
commit 0407102d70
5 changed files with 360 additions and 0 deletions

25
api/api.go Normal file
View File

@@ -0,0 +1,25 @@
package api
import (
"io"
"net/http"
"net/url"
"strings"
"github.com/spf13/viper"
)
func uploadDataToServer(httpClient *http.Client, data string) error {
params := url.Values{}
params.Set("token", viper.GetString("token"))
params.Set("data", data)
resp, err := httpClient.Post(viper.GetString("url")+"/api/data?"+params.Encode(), "application/x-www-form-urlencoded", strings.NewReader(""))
if err != nil {
return err
}
if resp != nil {
_, _ = io.Copy(io.Discard, resp.Body)
}
return err
}