I'am new in golang developing, i want to upload file to dropbox using golang, this is my curl command :
curl -X POST https://content.dropboxapi.com/2/files/upload --header "Authorization: Bearer <token>" --header "Dropbox-API-Arg: {\"path\": \"/file_upload.txt\",\"mode\": \"add\",\"autorename\": true,\"mute\": false}" --header "Content-Type: application/octet-stream" --data-binary @build.bat
this is my actual function :
func uploadFile(filename string, token string){
jsonData := make(map[string]string)
jsonData["path"] = "/file_upload.txt"
jsonData["mode"] = "add"
jsonData["autorename"] = true
jsonData["mute"] = false
req, err := http.NewRequest("POST", "https://content.dropboxapi.com/2/files/upload", nil)
if err != nil {
// handle err
}
req.Header.Set("Authorization", "Bearer "+token)
req.Header.Set("Dropbox-Api-Arg", "{\"path\": \"/file_upload.txt\",\"mode\": \"add\",\"autorename\": true,\"mute\": false}")
req.Header.Set("Content-Type", "application/octet-stream")
resp, err := http.DefaultClient.Do(req)
if err != nil {
// handle err
}
defer resp.Body.Close()
}
problem is i dont know how add --data-binary @build.bat in my go code, and how use my variable jsonData in Dropbox-Api-Arg set.