以下是我的样品卷曲要求。
QuerySqlFunction
我想用围棋语言做同样的事情。谁能帮我
我尝试以下
curl -X POST -F 'upload=@/home/user/file.txt' 'some_url' -H 'api: api_key' -H 'callback_url:callback_url'
答案 0 :(得分:-1)
package main
import (
"fmt"
"net/http"
"io/ioutil"
"os"
"log"
)
func main() {
data, err := os.Open("file.txt")
if err != nil {
log.Fatal(err)
}
var b bytes.Buffer
wr := multipart.NewWriter(&b)
part, err := wr.CreateFormFile("upload", filepath.Base("file.text"))
if err != nil {
fmt.Println("do something")
}
_, err = io.Copy(part, data)
wr.WriteField("api", "api_key")
wr.WriteField("callback_url", "callback_url")
wr.Close()
req, _ := http.NewRequest("POST", "url", &b)
req.Header.Set("api", "api_key")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := ioutil.ReadAll(res.Body)
fmt.Println(string(body))
}