Skip to content

Instantly share code, notes, and snippets.

@michaelgrifalconi
Last active January 18, 2019 10:20
Show Gist options
  • Save michaelgrifalconi/0e3c53e29f06e23128c5bc19c435e674 to your computer and use it in GitHub Desktop.
Save michaelgrifalconi/0e3c53e29f06e23128c5bc19c435e674 to your computer and use it in GitHub Desktop.
func newDropletUploadRequest(uri string, path string, uuid string) (*http.Request, error) {
file, err := os.Open(path)
if err != nil {
return nil, err
}
checksum, err := filesha256(file)
uri = uri + "/droplets/" + uuid + "/" + checksum
req, e := httputil.NewPutRequest(uri, map[string]map[string]io.Reader{
"droplet": map[string]io.Reader{"tempfile": file},
})
return req, e
}
//// part of main
req, err := newDropletUploadRequest(domain, path, fileUUID)
check(err)
resp, err := client.Do(req)
if err != nil {
panic(err)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment