Files
dypid-client/api/api.go
YGXB_net 0407102d70
Some checks failed
构建上传工具 / build-tool (push) Failing after 22s
feat: 添加文件上传工具及CI/CD配置
2025-10-11 12:34:06 +08:00

26 lines
511 B
Go

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
}