Last active
January 18, 2019 10:20
-
-
Save michaelgrifalconi/0e3c53e29f06e23128c5bc19c435e674 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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