Skip to content

Instantly share code, notes, and snippets.

@farhany
Created June 2, 2019 21:07
Show Gist options
  • Save farhany/dc97ecabc0cc97b4afb8c2a8756ac0e9 to your computer and use it in GitHub Desktop.
Save farhany/dc97ecabc0cc97b4afb8c2a8756ac0e9 to your computer and use it in GitHub Desktop.
// Source:
// Go Playground: https://play.golang.org/p/KjBCcudT1JF
package main
import (
"bytes"
"crypto/md5"
"encoding/hex"
"io"
"net/http"
"os"
)
func main() {
var f *os.File
buf := new(bytes.Buffer)
hash := md5.New()
io.Copy(io.MultiWriter(buf, hash), f)
req, _ := http.NewRequest("PUT", "https://example.com", buf)
req.Header.Set("Content-Md5", hex.EncodeToString(hash.Sum(nil)))
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment